Why NGINX returns 405 for a POST with a 504 GATEWAY TIMEOUT, and other Gotchas around its error page directive

NGINX' error_page directive keeps me busy, again. This week at engageSPARK we noticed a seemingly weird behavior by NGINX: On POST requests, NGINX would sometimes return a 405 METHOD NOT SUPPORTED response. This is weird, to say the least: Either your web application (the upstream server) supports POST or it …

How to Fix Nginx Soft 404: When a 404 Error Page Returns 200

Looking at Google Webmaster's Search Console, I noticed a crawl error:

The target URL doesn't exist, but your server is not returning a 404 (file not found) error.

Opening the URL, I got my custom (boring) 404 error page, and sure enough the status code of the HTTP response was …