S
S
Stepgor2020-07-28 15:21:10
Nginx
Stepgor, 2020-07-28 15:21:10

Why is load balancing not working in nginx?

The first time I work with distribution, here is the config. It listens to 2 different ports and in response gives the server number: 1 or 2. But it connects either always only to the first one, or only to the second one. And as far as I understand, according to the standard, it works in round-robin, and therefore it must alternate answers (1,2,1,2,1 ...). What's wrong?

upstream backends {
            server localhost:3222;
            server localhost:3221;
        }

        server {
            listen 443 ssl;
            ssl_certificate /etc/ssl/site.crt;
            ssl_certificate_key /etc/ssl/site.key;
            server_name site.xyz www.site.xyz;

            location / {
                proxy_set_header X-Real-IP $remote_addr;
                proxy_pass http://backends/;
            }
        }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2020-07-28
@Stepgor

Read again how the load is configured everything is written
here . You set limits for the number of active connections there and it will alternate backs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question