`
fourfireliu
  • 浏览: 95081 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

nginx负载均衡配置

阅读更多

测试服务器 tomcat 7.0.47 nginx 1.6.2

 

首先需要部署nginx服务器 假设为http://localhost:100080

两台tomcat服务器 http://localhost:7080 http://localhost:8080

 

在nginx 配置文件nginx.conf中修改如下

 

http block中添加upstream block:

   http{

      upstream test.fourfire.com {
       server localhost:8080;
       server localhost:7080;
      }

 server block修改:

     server {

        listen 10080;

        xxxxx

        location / {
            proxy_pass http://test.fourfire.com;
        }
     }

 

修改完毕 执行sudo ./nginx -s reload 即可

若需要设置不同tomcat权重不同的负载均衡

只需要修改为

server localhost:8080 wegiht=2; 然后sudo ./nginx -s reload 即可 这样访问8080端口的请求/7080端口请求 比例约为2:1

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics