'Dynamic proxy_pass in nginx based on query string value

How to dynamic proxy_pass in nginx based on query string
for example if user call http://example.com/print?host=project1 this URL
I need to proxy pass this URL to http://project1:3333
project1 is available in my local network only
Now my nginx conf look like

proxy_pass http://$arg_host:3333

It won't work. Any suggestions to achieve this Thanks in advance.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source