Can I proxy_pass to a variable?

任晓磊 julyclyde at
Mon May 10 07:54:45 MSD 2010

server {
        listen [::]:80 default;
        server_name _ ;
        server_name_in_redirect off;

        access_log  off;

        auth_basic      "Private proxy";
        auth_basic_user_file /etc/nginx/auth_basic_user;

        location /{
                proxy_pass http://$http_host;
                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

2010/05/10 11:02:25 [error] 31032#0: *45 zero length URI to proxy,
client: ::ffff:, server: _, request: "GET HTTP/1.1", host: ""

If a specify an IP address or a domain name in proxy_pass, it worked.
I use $http_host, it doesnt work. How can I do?
# /usr/sbin/nginx -V
nginx version: nginx/0.7.64
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf
--pid-path=/var/run/ --lock-path=/var/lock/nginx.lock
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug
--with-http_stub_status_module --with-http_flv_module
--with-http_ssl_module --with-http_dav_module
--with-http_gzip_static_module --with-mail --with-mail_ssl_module
--with-ipv6 --add-module=/tmp/buildd/nginx-0.7.64/modules/nginx-upstream-fair

Ren Xiaolei

More information about the nginx mailing list