Define an upstream group so Nginx can send requests to multiple application instances. Then decide how to distribute work and when to temporarily avoid a failing instance.
Start with two application servers
Inside http, the following illustrative configuration distributes traffic to two private addresses:
upstream app {
server 10.0.0.11:3000 max_fails=2 fail_timeout=10s;
server 10.0.0.12:3000 max_fails=2 fail_timeout=10s;
}
server {
listen 80;
location / {
proxy_pass http://app;
}
}
With equal weights, the default round-robin method takes turns across servers. The example's and let qualifying failures temporarily exclude a server. The numbers illustrate behavior; choose production values from your traffic and failure tolerance.
