Ошибка Nginx: ошибка подключения () (10061) при подключении к вышестоящему клиенту

#nginx #load-balancing #reverse-proxy

#nginx #балансировка нагрузки #обратный прокси-сервер

Вопрос:

У меня есть сервер Nginx, работающий в качестве обратного прокси — сервера и балансировщика нагрузки для 3 серверов. Вот мой .conf

 worker_processes 1;  events {  worker_connections 1024; }   http {  include mime.types;  sendfile on;  tcp_nopush on;  tcp_nodelay On;   keepalive_timeout 65;   upstream worker_server {  hash $remote_addr consistent;  server localhost:40090;  server localhost:40091;  }   upstream master_server {  server localhost:40089;  }   server {  listen 88;   location / {  proxy_pass http://worker_server;  proxy_http_version 1.1;  proxy_set_header Connection "Upgrade";  proxy_set_header Host $host;  proxy_set_header Upgrade $http_upgrade;  proxy_set_header X-Real-IP $remote_addr;  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  proxy_set_header X-Forwarded-Proto $scheme;  }   location ~ ^/(Main|Monitor|Live) {  proxy_pass http://master_server;  proxy_http_version 1.1;  proxy_set_header Connection "Upgrade";  proxy_set_header Host $host;  proxy_set_header Upgrade $http_upgrade;  proxy_set_header X-Real-IP $remote_addr;  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  proxy_set_header X-Forwarded-Proto $scheme;   }  location ~.*.(gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|txt|js|css|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|woff|ttf|svg|eot)$ {  proxy_pass http://master_server;  gzip_static on;  expires 7d;  }  }  }  

Ошибка возникает при запросе нескольких ресурсов:

 2021/12/08 12:30:31 [error] 14596#15056: *398 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /Main?_SID=2*5306343 HTTP/1.1", upstream: "http://[::1]:40089/Main?_SID=2*5306343", host: "localhost:88", referrer: "http://localhost:88/login()" 2021/12/08 12:30:33 [error] 14596#15056: *398 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /style.css HTTP/1.1", upstream: "http://[::1]:40090/style.css", host: "localhost:88", referrer: "http://localhost:88/Main?_SID=2*5306343" 2021/12/08 12:30:44 [error] 14596#15056: *456 connect() failed (10061: No connection could be made because the target machine actively refused it) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /monitor HTTP/1.1", upstream: "http://[::1]:40089/monitor", host: "localhost:88"  

Когда я перезагружаю ту же страницу, другой ресурс выдает ошибку и вызывает 2-секундное замедление на стороне клиента.