Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#824 closed defect (worksforme)

NGINX returning 404 on proxy timeout instead of 504 when request is a POST

Reported by: brad.getsensibill.com@… Owned by:
Priority: minor Milestone:
Component: nginx-module Version: 1.4.x
Keywords: Cc:
uname -a: Linux testing-1 3.13.0-46-generic #79-Ubuntu SMP Tue Mar 10 20:06:50 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
nginx -V: nginx version: nginx/1.4.6 (Ubuntu)

Description

Hello,

We have been diagnosing a strange issue in our systems error handling and believe the culprit may be Nginx.

We use Nginx as a proxy to our internal API server. Our API server misbehaves sometimes and times out. Normally, when this happens, Nginx issues a 504 bad gateway. However, if the request happens to be a POST request, it appears that NGINX issues a 404 Page Not Found error.

Change History (3)

comment:1 by Maxim Dounin, 8 years ago

Unless you've configured nginx to return a custom error page for 504 errors using the error_page directive - there is no difference for nginx if a request was GET or POST, it will just return a built in error page for the error. If, however, you've configured custom error page for 504, such an error page may do arbitrary request processing and can, in particular, return 404. Though in this case nginx only does what it is configured to do, and this is no a bug.

If you think that error you are facing is a result of an nginx bug, and not your configuration problem - please provide full minimal configuration necessary to reproduce the problem and/or debug log which demonstrates it.

comment:2 by Maxim Dounin, 8 years ago

Resolution: worksforme
Status: newclosed

Feedback timeout.

comment:3 by patrick.robinson.envato.com@…, 8 years ago

Though in this case nginx only does what it is configured to do, and this is no a bug.

This is rather un-expected though and should be documented in the error_page documentation. The issue appears to only occur if you use a named location with error_page, i.e:

error_page 502 504 @50x

location @50x {
  rewrite ^(.*) /50x.html
}

Although this causes a 405 in my case not a 404, since it's trying to POST to a static page.

If you use a path to the error page instead then POST renders the correct error page:

error_page 502 504 /50x.html
Note: See TracTickets for help on using tickets.