I'm using nginx as a reverse proxy and I would like it to wait some number of seconds and retry a request if the upstream server isn't responding. This way I can restart my upstream server and instead of users seeing 502 bad gateway, their browsers just hang for a few seconds (the restart process takes 3 or 4 seconds). I've tried a couple things, I put this in my server block:
proxy_connect_timeout 60;
proxy_send_timeout 15;
proxy_read_timeout 20;
but it didn't seem to do anything. I also tried adding this to the upstream block:
server 127.0.0.1:3001 fail_timeout=10s;
again, not what I wanted.
Is this possible? What am I missing?