On Friday, September 30, 2016 12:55 AM Francis Daly wrote,
>> No, I have an "error_page 503" and a similar one for 404 that points to two >> named locations, but that's it. > That might matter. > I can now get a 503, 404, or 405 result from nginx, when upstream sends a 503. [...] > Now make /tmp/x exist, and /tmp/y not exist. > > A GET request for /x is proxied, gets a 503, and returns the content of > /tmp/x with a 503 status. > > A GET request for /y is proxied, gets a 503, and returns a 404 status. > > A POST request for /x is proxied, gets a 503, and returns a 405 status. > > A POST request for /y is proxied, gets a 503, and returns a 404 status. > > Since you also have an error_page for 404, perhaps that does something that > leads to the output that you see. > > I suspect that when you show your error_page config and the relevant > locations, it may become clearer what you want to end up with. My local test config looks like this (log specifications and other stuff left out): server { listen 80; server_name localhost; location / { root html; try_files /offline.html @xact; add_header Cache-Control "no-cache, max-age=0, no-store, must-revalidate"; } location @xact { proxy_pass http://127.0.0.1:4431; proxy_redirect default; proxy_read_timeout 2s; proxy_send_timeout 2s; proxy_connect_timeout 2s; proxy_intercept_errors on; } error_page 404 @error_404; error_page 503 @error_503; location @error_404 { root error; rewrite (logo.png)$ /$1 break; rewrite ^(.*)$ /error404.html break; } location @error_503 { root error; rewrite (logo.png)$ /$1 break; rewrite ^(.*)$ /error503.html break; } > A test system which talks to a local HAProxy which has no "up" backends > would probably be quicker to build. Yes, thats what I had listening on 127.0.0.1:4431, and it did give me the same behaviour as I'm seeing in our production environment. I got the following captures via pcap and wireshark: Conditions are: HAProxy has a backend with no available servers, so every request results in a 503 to upstream client (nginx). A POST request to some resource from a browser: POST /2 HTTP/1.1 Host: localhost User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en Accept-Encoding: gzip, deflate DNT: 1 Content-Type: application/x-www-form-urlencoded Content-Length: 0 Cookie: new-feature=1; Language_In_Use= Connection: keep-alive This makes nginx send this request to HAProxy: POST /2 HTTP/1.0 Host: 127.0.0.1:4431 Connection: close Content-Length: 0 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en Accept-Encoding: gzip, deflate DNT: 1 Content-Type: application/x-www-form-urlencoded Cookie: new-feature=1; Language_In_Use= HAProxy returns this: HTTP/1.0 503 Service Unavailable Cache-Control: no-cache Connection: close Content-Type: text/html <html><body><h1>503 Service Unavailable</h1> No server is available to handle this request. </body></html> HAProxy also logs this (raw syslog packet): <134>Oct 15 13:17:33 jedc-local haproxy[10104]: 127.0.0.1:64746 [15/Oct/2016:13:17:33.800] xact_in-DK xact_admin/<NOSRV> 0/-1/-1/-1/0 503 212 - - SC-- 0/0/0/0/0 0/0 "POST /2 HTTP/1.0" This makes nginx return this back to the browser: HTTP/1.1 405 Not Allowed Server: nginx/1.8.0 Date: Sat, 15 Oct 2016 11:17:33 GMT Content-Type: text/html Content-Length: 172 Connection: keep-alive nginx also logs this: localhost 127.0.0.1 "-" [15/Oct/2016:13:17:33 +0200] "POST /2 HTTP/1.1" 405 172 503 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0" http "-" "-" "-" "-" -/- There is no mention of the error_page 503 location or any of the resources they specify (logo.png or error503.html) in any of nginx' logs, so I assume that they are not really connected to the problems I see. Any ideas? Regards, Jens Dueholm Christensen
_______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx