英文:
Setting up nginx for fault tolerance
问题
我有两台后端服务器。我需要配置nginx配置,以便当一台服务器出现故障时,切换到第二台后端服务器。
不幸的是,我只找到了关于多个后端服务器之间的负载分配的信息。
我以前没有使用过nginx,只了解标准配置设置。
英文:
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
答案1
得分: 0
好的,以下是翻译好的部分:
"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)"
英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论