I am using NGINX as a reverse proxy for a new webapp interface over an old service.
NGINX serves the static resources and forwards the API requests over to the old server (also hiding it from the public, as it cannot have an A+ SSL setup)
Time to time I receive 504 gateway timeout responses, It feels like NGINX re-uses connections and the webserver from the other side doesn't respond anymore after re-using it for too long.
The solution is very easy, a simple sudo service nginx restart
fixes those gateway timeouts, still I would like to fix this "glitch" once and for all.
Simple diagram:
Users New Website (NGINX) Old Website (ASP?)
/ <<< serves index.html
/api/item <<< change headers and forward >>> API request >\
|
<<< change headers and forward <<< API response </
HTTP status 504 means that the upstream server is down or slow to respond within your specified timeout.
Increase your proxy_<*>_timeout
and reload nginx.
Find the directives here - http://nginx.org/en/docs/http/ngx_http_proxy_module.html