S
S
Satisfied IT2019-07-31 15:55:47
Nginx
Satisfied IT, 2019-07-31 15:55:47

Failover with nginx, what should I do in my situation?

There are two web servers, database synchronization is configured between them, etc. and they are always identical. On the third server, there is nginx and through proxy_passit receives traffic from one of the servers and gives it to the world. We want to set up such a scheme - if the first server suddenly crashes, then nginx automatically starts sending traffic from the second server. I read about upstreamsomething similar, but I don’t like that it balances the load, and does not switch to the second server when the first one is unavailable (and vice versa), I don’t need balancing in this case. Please point me in the right direction or solution.
PS I read that the server can be specified as a backup and after that it will be used if the others are not available, but I still don’t understand whether it is possible to specify one main and one backup, something like this

upstream test_upstream {
    server    server1.server.com;
    server    server2.server.com backup;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Shumov, 2019-07-31
@inoise

Haproxy for balancing and health check, well, or play around with HashiCorp Consul. But you still take out the database on a separate server, if possible. Do not do it this way

P
paran0id, 2019-07-31
@paran0id

In principle, this can be done, it will work. If you don't like that nginx load balances (why don't you like it?), you can make one backup or distribute the load using weights.
But it's better to do this:
- two frontend servers
- virtual ip (corosync, keepalived), migrating from one to another in case of failure
- haproxy listens on virtual ip, distributing the load between the fronts
- nginx on the fronts distributes the load between the backends
- backend servers two or more, both work simultaneously, can be scaled by adding servers
- the base is separated if possible, also spaced into two or more servers, with replication

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question