I'm also interested in the explanation, as I have a bunch of servers with:
upstream backend{
server localhost:8080 fail_timeout=1s;
server localhost:80 backup;
}
And I eventually see requests being honored by localhost:80 backup server.
Both servers, the live application proxyed server and the nginx based static fallback are on the same machine, and whenever localhost:8080 serves a request that has a modified content since the last checksum (ETag), it passivates the content on disk for the static fallback server to serve in case of proxy_next_upstream.
So what I'm wondering, along with those questions made by Harish, is:
1) what are the consequences of having fail_timeout=1s? Does that mean that if I have maxfails in one second then the backup server will serve the very request who failed, or the next one?
2) how long nginx would be serving static content until the upstream come back to whatever normality is restored?
3) how is the best way to have a backup server definition at the upstream to serve static content in the event of proxy_next_upstream?
Thanks