Sem William Cersosimo
Sem William Cersosimo

Reputation: 15

Nginx failover no load balancing only if fail

Hi i'm using nignx for reverse porxy. I just want to send my all requests to my first server. But if the first server is down, I want to send requests to second one.

I have tried that:

    upstream backend {
        server 1.1.1.1 max_fails=1 fail_timeout=5s;
        server 1.2.2.2 backup;
    }

    server {
        listen  80;
        server_name example.com;

    location / {
            proxy_pass              http://backend;
    }
    }

Seems my nginx can't understand the "backup" string My version: 1.8.0

Upvotes: 1

Views: 1542

Answers (1)

user21719190
user21719190

Reputation:

By default, NGINX implements round robin load balancing.So, the load will go cycle from 1.1.1.1 to 2.2.2.2. What you're trying isn't possible in NGINX open source.

Upvotes: 0

Related Questions