http {
upstream backend {
server 192.168.3.213:8078 max_fails=3 fail_timeout=30s;
server 192.168.3.213:8077 backup;
}
server {
listen 8047;
server_name localhost;
location /api/ {
proxy_set_header Host $host;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend/;
}
}
}
当8078宕机后,Nginx可将请求代理到8077