Nginx负载均衡配置

(1)关键配置信息

(2)配置文件

worker_processes  1;

events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    keepalive_timeout  65;

    upstream article {
        server 192.168.11.3:8089;
        server 192.168.11.3:8088 ;
    }
    server {
        listen       80;
        server_name  localhost;

        location / {
          #  root   html;
           # index  index.html index.htm;
            add_header 'Access-Control-Allow-Origin' '*';
            proxy_pass http://article;
        }
        
        location /xmkkj {
            include  uwsgi_params;
            proxy_pass   http://192.168.11.3:8082;
       }
       
        location /xmkj {
            include  uwsgi_params;
            proxy_pass   http://192.168.11.3:8084;
       }
        
        location /xmkj2 {
            include  uwsgi_params;
            proxy_pass   http://192.168.11.3:8084;
       }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    }


}

(3)效果

通过访问:http://192.168.11.3:80/article/

可以访问到:http://192.168.11.3:8088/article/,http://192.168.11.3:8089/article/

原文地址:https://www.cnblogs.com/excellencesy/p/11949736.html