I have two backend server. I need to configure the nginx config so that when one server falls off, it switches to the second backend server
Unfortunately I found only about load distribution between several backend servers
I didn't work with nginx before only standart config setting
Okey, it was so easy In config need add directive
upstream backends {
server backend1;
server backend2 backup;
}
Backup - is options for 2nd server is the one that will rise when 1st server goes down.
After that in directive location / {} You need add
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_next_upstream - this shows for which returned errors it is necessary to transfer to another server. And when it catch this errors, he can change backend1 to backend2(backup server)