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 …