On a local development machine i have an nginx reverse proxy like this

server {
  listen 80;
  server_name myvirtualhost1.local;
  location / {
    proxy_pass http://127.0.0.1:8080;
}

server {
  listen 80;
  server_name myvirtualhost2.local;
  location / {
    proxy_pass http://127.0.0.1:9090;
}

Yet if i debug my application, the response may be delayed for an infinite amount of time, yet after 30 seconds i get.

504 Gateway Time-out

as a response.

Tell me the best way to disable timeout and have a reverse proxy wait forever for responses? And i like the setting to be global so that i don't have to set it for every proxy

Best Answer


It may not be possible to disable it at all yet a feasible workaround is to increase the execution time On a nginx tutorial site , it was written.

If you want to increase time-limit for all-sites on your server, you can edit main nginx.conf file:

vim /etc/nginx/nginx.conf

Add following in http{..} section

http {
     fastcgi_read_timeout 300;
     proxy_read_timeout 300;
}

and reload nginx' config.

sudo service nginx reload

I have used a rather large value that is unlikely to happen, i.e. 999999 or using time units , to one day via 1d .

Beware that setting the value to 0 will cause a gateway timeout error immediately.