On Sat, Oct 15, 2016 at 12:18:11PM +0000, Jens Dueholm Christensen wrote:
> On Friday, September 30, 2016 12:55 AM Francis Daly wrote,

Hi there,

> > 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):

>         location / {
>             root html;
>             try_files /offline.html @xact;
>         }
>         location @xact {
>             proxy_pass;
>             proxy_intercept_errors on;
>         }
>         error_page 503 @error_503;
>         location @error_503 {
>                 root error;
>                 rewrite (logo.png)$ /$1 break;
>                 rewrite ^(.*)$ /error503.html break;
>         }

So: a POST for /x will be handled in @xact, which will return 503,
which will be handled in @error_503, which will be rewritten to a POST
for /error503.html which will be sent to the file error/error503.html,
which will return a 405.

Is that what you see?

Two sets of questions remain:

what output do you get when you use the test config in the earlier mail?

what output do you want?

That last one is probably "http 503 with the content of *this* file";
and is probably completely obvious to you; but I don't think it has been
explicitly stated here, and it is better to know than to try guessing.

> 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>

Ok, that's a normal 503.

> HAProxy also logs this (raw syslog packet):
>   <134>Oct 15 13:17:33 jedc-local haproxy[10104]: 
> [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

And that's the 405 because your config sends the 503 to a static file.

> nginx also logs this:
>   localhost "-" [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.

Unless you are looking at the nginx debug log, you are not seeing anything
about nginx's internal subrequests.

If you remove the error_page 503 part or the proxy_intercept_errors part,
does the expected http status code get to your client?

> Any ideas?

I think that the nginx handling of subrequests from a POST for error
handling is a bit awkward here. But until someone who cares comes up with
an elegant and consistent alternative, I expect that it will remain as-is.

Possibly in your case you could convert the POST to a GET by using
proxy_method and proxy_pass within your error_page location.

That also feels inelegant, but may give the output that you want.


Francis Daly        fran...@daoine.org

nginx mailing list

Reply via email to