Why doesn't the nginx load balance I configured work?


-sharpuser  nobody;
worker_processes  1;

-sharperror_log  logs/error.log;
-sharperror_log  logs/error.log  notice;
-sharperror_log  logs/error.log  info;

-sharppid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

 
    sendfile        on;

    keepalive_timeout  65;


    
    upstream  mzd {
    
       server 127.0.0.1:8082;
       server 127.0.0.1:8081;
    }

    server {
        listen       80;
        server_name  www.tuesdayma.com;


        location / {
            proxy_pass  http://mzd;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }


}
The

configuration file is like this, and 8082 and 8081 are accessible. But when I visit http://www.tuesdayma.com/. . Why is that? The default is not polling, in theory, it should be 8082 allocation, 8081 allocation once.

Apr.02,2021

try adding a weight, but it may not be solved. It is best to take a look at the log
.
server 127.0.0.1:8082 weight=1 max_fails=5 fail_timeout=30s;
server 127.0.0.1:8081 weight=1 max_fails=5 fail_timeout=30s;

I have the same problem with you. It's useless to restart nginx. Just restart the computer.

Menu