Nginx Backup


1 min read

Nginx config:

upstream myapp1 {
    server max_fails=1 fail_timeout=10s;
    server backup;

If there is 1 fail in 10 seconds, then send all requests to the backup server (9002) and keep sending requests to 9002 for 10 seconds; After 10 seconds, Nginx will try the primary server (9001) again to see if it is back, if it is back, then switch to send request to 9001, otherwise, keep using 9002.