how to use $host variable in proxy_pass

hirenshah.05 nginx-forum at
Wed Dec 28 18:42:41 UTC 2011

I want to use $host variable in proxy_pass. If directly hardcode
Hostname in proxy_pass it is working fine. But if I use variable $host
it is giving me "502 Bad Gateway"

server {
        listen      80;
        server_name  "";

        location / {
            proxy_pass;            //working fine
            proxy_pass https://$host;                   //gives error.
And $host value is same like above hostname ""
            proxy_redirect  off;


Thanks for help.

Posted at Nginx Forum:,220619,220619#msg-220619

More information about the nginx mailing list