问题原文
原帖链接 · Serhat · CC BY-SA 3.0
I'm having trouble configuring nginx.
I'm using nignx as a reverse proxy. I want to send my all requests to my first server. If the first server is down, I want to send requests to second server.
In short, how can I have a failover solution without load balancing?
已采纳解答
原帖链接 · chrskly · CC BY-SA 3.0
What you want is an active+passive setup. Here's an example nginx conf snippet to get you going:
upstream backend {
server 1.2.3.4:80 fail_timeout=5s max_fails=3;
server 4.5.6.7:80 backup;
}
server {
listen 80;
server_name whatevs.com;
location / {
proxy_pass http://backend;
}
}
So, 'normally', all requests will go to host 1.2.3.4. If we get three failures to that box, then 4.5.6.7 will take over.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
