Nginx 配置反向代理及负载均衡的实现

一、nginx的反向代理及多台虚拟机负载均衡的实现

 

主机负载均衡服务器:192.168.232.132 的nginx.conf 配置如下

http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    #gzip  on;
    
    upstream myproxy {
        ip_hash;
        server 192.168.232.129:8888;
        server 192.168.232.128:8081;
    }
    
    server {
        listen       80;
        server_name  localhost;

        location / {
            proxy_pass http://myproxy;
        }

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

    }
}

二、两台web服务器如下:

        server 192.168.232.129:8888;
        server 192.168.232.128:8081;


posted @ 2020-03-27 18:10  王默默  阅读(266)  评论(0编辑  收藏  举报