csg
September 28, 2011 03:35PM
Maxim Dounin Wrote:
-------------------------------------------------------
Hello again!

> .... and $backend won't be set as a result.
> Moving "set" before
> "rewrite .. break" will do the trick.

Right, in this case the $backend applies to proxy_pass and the request gets proxied but unfortunatelly in this case the rewrite rule does not have effect anymore. It still gets applied according to the error logs, but instead of the rewritten URL path to original one gets proxied. To make it more clear I changed the example configuration I posted above by having each virtual host its own access and error log.

When I run following test ...

$ curl -s -o - -D - http://localhost:92/foo/
HTTP/1.1 404 Not Found
Server: nginx
Date: Wed, 28 Sep 2011 19:26:04 GMT
Content-Type: text/html
Connection: keep-alive
Content-Length: 162

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

I will get this in the error logs

# tail -F /var/log/nginx/{access,error}9[012].log
==> /var/log/nginx/access90.log <==
127.0.0.1 - - [28/Sep/2011:21:26:04 +0200] "GET /foo/ HTTP/1.0" 404 162 "-" "curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5"

==> /var/log/nginx/access92.log <==
127.0.0.1 - - [28/Sep/2011:21:26:04 +0200] "GET /foo/ HTTP/1.1" 404 162 "-" "curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5"

==> /var/log/nginx/error90.log <==
2011/09/28 21:26:04 [error] 3078#0: *15 "/usr/share/nginx/html/foo/index.html" is not found (2: No such file or directory), client: 127.0.0.1, server: _, request: "GET /foo/ HTTP/1.0", host: "localhost:90"

==> /var/log/nginx/error92.log <==
2011/09/28 21:26:04 [notice] 3078#0: *13 "^/foo/(.*)$" matches "/foo/", client: 127.0.0.1, server: _, request: "GET /foo/ HTTP/1.1", host: "localhost:92"
2011/09/28 21:26:04 [notice] 3078#0: *13 rewritten data: "/", args: "", client: 127.0.0.1, server: _, request: "GET /foo/ HTTP/1.1", host: "localhost:92"
2011/09/28 21:26:04 [notice] 3078#0: *13 "^/foo/(.*)$" does not match "/", client: 127.0.0.1, server: _, request: "GET /foo/ HTTP/1.1", host: "localhost:92"
2011/09/28 21:26:04 [info] 3078#0: *13 client 127.0.0.1 closed keepalive connection

If this in not what you would expect, I can rebuild Nginx with --with-debug tomorrow and repeat the test.
Subject Author Posted

Does Nginx honor DNS TTLs for proxy upstreams?

csg September 26, 2011 04:42AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 26, 2011 05:38AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 26, 2011 09:40AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 26, 2011 09:58AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 28, 2011 12:05PM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 28, 2011 12:14PM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 28, 2011 03:35PM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 29, 2011 03:31AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 29, 2011 03:32AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg September 29, 2011 03:53AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

Maxim Dounin September 29, 2011 03:30AM

Re: Does Nginx honor DNS TTLs for proxy upstreams?

csg October 04, 2011 04:12AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 284
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