how to use $host variable in proxy_pass

hirenshah.05 nginx-forum at nginx.us
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 https://cds.hh.net;            //working fine
            proxy_pass https://$host;                   //gives error.
And $host value is same like above hostname "cds.hh.net"
            proxy_redirect  off;
        }

}

Thanks for help.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,220619,220619#msg-220619



More information about the nginx mailing list