跳到主要内容
  1. Posts/

Nginx 配置负载均衡

··44 字·1 分钟·

配置 nginx.conf #

upstream tomcat{
    # 服务器性能较好,权重设置为 2
    server  192.168.0.100:8080 weight=2;
    # 服务器性能较弱,权重设置为 1
    server  192.168.0.101:8080 weight=1;
}

server {
    listen       80;
    server_name  localhost;

    #access_log  logs/host.access.log  main;

    location / {
        #root   html;
        #index  index.html index.htm;
        proxy_pass http://tomcat;
    }
}

效果 #

每三个请求,会有两个访问 8080 服务器,一个访问 8081 服务器