Nginx-0.6.20

Changes with nginx 0.6.20 28 Nov
2007

*) Bugfix: a segmentation fault might occur in worker process if a
   "proxy_pass" directive with URI-part was used; bug appeared in
   0.6.19.

anyone have an working example of the new proxy pass with URI directive?

Thanks

Igor S. [email protected] wrote: Changes with nginx 0.6.20
28 Nov 2007

*) Bugfix: a segmentation fault might occur in worker process if a
   "proxy_pass" directive with URI-part was used; bug appeared in
   0.6.19.


Igor S.
http://sysoev.ru/en/

On Wed, Nov 28, 2007 at 04:55:25PM -0800, Eire A. wrote:

anyone have an working example of the new proxy pass with URI directive?

It’s not a new proxy_pass, it’s old one that has been broken:

  locaiton /one/ {
      proxy_pass  http://localhost/two/;
  }

“/two/” is URI-part.

The proxy_pass supports variables, for example:

 proxy_pass  http://$host$uri;

and the the host part will be resolved on the fly.

On Thu, 2007-11-29 at 09:22 +0300, Igor S. wrote:

On Wed, Nov 28, 2007 at 04:55:25PM -0800, Eire A. wrote:

The proxy_pass supports variables, for example:

 proxy_pass  http://$host$uri;

and the the host part will be resolved on the fly.

Upgraded to Nginx 0.6.20.

I tried once again to use:

http {
map $host $backend {
hostnames;
.cellarstella.com 127.0.0.6:8000;
}

server {
    server_name cellarstella.com www.cellarstella.com;

    location / {
            # proxy_pass http://127.0.0.6:8000; # this works
            proxy_pass http://$backend;
            include /etc/nginx/proxy.conf;
    }
}

}

But I get this in the error log:

2007/11/29 10:35:52 [error] 2698#0: *28 no resolver defined to resolve
127.0.0.6, client: 67.189.89.59, server: www.cellarstella.com, request:
“GET / HTTP/1.1”, host: “www.cellarstella.com

Is “map” not yet supported for proxy_pass or am I just doing it wrong?

Regards,
Cliff

On Thu, 2007-11-29 at 22:06 +0300, Igor S. wrote:

}

But I get this in the error log:

2007/11/29 10:35:52 [error] 2698#0: *28 no resolver defined to
resolve 127.0.0.6, client: 67.189.89.59, server: www.cellarstella.com,
request: “GET / HTTP/1.1”, host: “www.cellarstella.com

query to the resolver, but use the ip address.
Indeed this fixed it. However, what’s not clear to me is why Nginx
tries to resolve 127.0.0.6 since it is an IP address.

Cliff

On Thu, 2007-11-29 at 22:06 +0300, Igor S. wrote:

First, you need add URI-part:

  •          proxy_pass http://$backend;
    
  •          proxy_pass http://$backend$request_uri;
    

Out of curiosity: this worked before without $request_uri. Is this
requirement due to some side-effect from using a variable?

Regards,
Cliff

On Thu, Nov 29, 2007 at 11:39:48AM -0800, Cliff W. wrote:

query to the resolver, but use the ip address.

Indeed this fixed it. However, what’s not clear to me is why Nginx
tries to resolve 127.0.0.6 since it is an IP address.

This is commom code path. Upstream code asks resolver code to resolve
host.
Upstream code does not know that it is IP. Anyway, if you use IPs only,
you
may set

 resolver 127.0.0.1;

and do not run local DNS server on the computer.

On Thu, Nov 29, 2007 at 10:49:09AM -0800, Cliff W. wrote:

Upgraded to Nginx 0.6.20.

}

But I get this in the error log:

2007/11/29 10:35:52 [error] 2698#0: *28 no resolver defined to resolve 127.0.0.6, client: 67.189.89.59, server: www.cellarstella.com, request: “GET / HTTP/1.1”, host: “www.cellarstella.com

Is “map” not yet supported for proxy_pass or am I just doing it wrong?

First, you need add URI-part:

  •          proxy_pass http://$backend;
    
  •          proxy_pass http://$backend$request_uri;
    

Second, after proxy_pass has parsed string it tries to resolve a host in
following order:

  1. search all described upstreams,

  2. try external resolver (named/bind/etc); you should define it
    in http, server, or location section:

    resolver 127.0.0.1;
    

    however, if the host is an ip address, then nginx does not send DNS
    query to the resolver, but use the ip address.

On Thu, Nov 29, 2007 at 06:41:28PM -0800, Cliff W. wrote:

On Thu, 2007-11-29 at 22:06 +0300, Igor S. wrote:

First, you need add URI-part:

  •          proxy_pass http://$backend;
    
  •          proxy_pass http://$backend$request_uri;
    

Out of curiosity: this worked before without $request_uri. Is this
requirement due to some side-effect from using a variable?

Yes, there is some disparity.

Before proxy_pass supports two forms

  1. like root: proxy_pass http:/host:port
  2. like alias: proxy_pass http:/host:port/uri

With variable support we can easy support “root” functionality.
But how we can to separate alias from full URL ?
May be so

  proxy_pass         $url;          # alias
  proxy_pass_full    $url;          # full URL

?

On Fri, Nov 30, 2007 at 09:50:48AM +0300, Igor S. wrote:

Out of curiosity: this worked before without $request_uri. Is this
May be so

  proxy_pass         $url;          # alias
  proxy_pass_full    $url;          # full URL

?

Other way: rename old
proxy_pass http://host:port/uri
to
proxy_alias http://host:port/uri
and issue warning to use proxy_alias instead of proxy_pass.

On Fri, 2007-11-30 at 11:25 +0300, Igor S. wrote:

With variable support we can easy support “root” functionality.
to
proxy_alias http://host:port/uri
and issue warning to use proxy_alias instead of proxy_pass.

Oh, I have no problem with it. I only wanted to understand and make
sure it is documented properly on the wiki.

Regards,
Cliff

On Fri, Nov 30, 2007 at 02:11:24PM -0800, Cliff W. wrote:

  •          proxy_pass http://$backend$request_uri;
    
proxy_pass   http://host:port/uri

to
proxy_alias http://host:port/uri
and issue warning to use proxy_alias instead of proxy_pass.

Oh, I have no problem with it. I only wanted to understand and make
sure it is documented properly on the wiki.

I’m going to implemnt proxy_alias.

On Fri, Nov 30, 2007 at 09:54:20AM +0300, Igor S. wrote:

 resolver 127.0.0.1;

and do not run local DNS server on the computer.

I will implement resolver stub that allows to use IPs witout resolver
declaration.