Welcome! Log In Create A New Profile

Advanced

Re: Can I proxy_pass to a variable?

May 10, 2010 02:10AM
On Mon, May 10, 2010 at 11:54:45AM +0800, 任晓磊 wrote:

> config:
> server {
> listen [::]:80 default;
> server_name _ ;
> server_name_in_redirect off;
> resolver 74.207.241.5;
>
> 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;
> }
> }
>
> error.log:
> 2010/05/10 11:02:25 [error] 31032#0: *45 zero length URI to proxy,
> client: ::ffff:124.205.200.99, server: _, request: "GET
> http://www.whatismyip.com/ HTTP/1.1", host: "www.whatismyip.com"
>
>
> 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

You have to write:

proxy_pass http://$http_host$request_uri;

Since 0.8.25 and 0.7.65, you may write:

proxy_pass http://$http_host;


--
Igor Sysoev
http://sysoev.ru/en/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Can I proxy_pass to a variable?

任晓磊 May 09, 2010 11:58PM

Re: Can I proxy_pass to a variable?

Boris Dolgov May 10, 2010 02:06AM

Re: Can I proxy_pass to a variable?

Igor Sysoev May 10, 2010 02:10AM

Re: Can I proxy_pass to a variable?

任晓磊 May 10, 2010 04:34AM

Re: Can I proxy_pass to a variable?

Igor Sysoev May 10, 2010 04:58AM

Re: Can I proxy_pass to a variable?

任晓磊 May 10, 2010 05:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 166
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready