failover – effect of fail_timeout and max_fails in upstream in nginx

I have a public facing nginx server acting as reverse proxy for an on-premises upstream server. I have two ISP providers so I want nginx to failover to the backup ISP whenever primary ISP fails.

Criteria:

  • I want to failover to backup line at the very first connection problem.
  • Whenever the failover happens, I want to stick to the backup line(if backup line is functional) for 30s before retying primary line.

Below is the upstream config I made by referring various snippets available online:

upstream remote_server {
    server 1.2.3.4:443 fail_timeout=10 max_fails=1; # primary_line_ip
    server 5.6.7.8:443 fail_timeout=30 backup; # backup_line_ip
}

However, I need help with below questions:

  1. What does fail_timeout=10 indicate? – Does it mean that nginx will wait for 10s for connection to timeout before failover?
  2. What are the implications of setting fail_timeout=0? – Does it mean that nginx will always try all the request on primary line and use backup only if primary fails?

Read more here: Source link