首页 > 其他 > 详细

nginx负载均衡集群

时间:2016-01-09 06:21:24      阅读:170      评论:0      收藏:0      [点我收藏+]

网络7层

nginx的负载均衡和lvs相比,nginx属于更高级的应用层,不牵扯到IP和内核的改动,它只是单纯地把用户的请求转发到后面的机器上。这就意味着,后端的RS不需要配置公网IP。

nginx分发器(一个公网ip192.168.31.166 和一个内网ip192.168.21.166)。 

RS1只有内网ip(192.168.21.100) 

RS2只有内网ip(192.168.21.101)

在nginx分发器上编辑配置文件 

# vim /usr/local/nginx/conf/vhosts/lb.conf 

加入如下内容


upstream test {

  

  ip_hash;


    server 192.168.1.122; weight=2


     server 192.168.1.124; weight=1

 

 }



     server {


            listen 80;


            server_name bbs.aaa.cn;



            location / {

 

               proxy_pass      http://test/;


                proxy_set_header Host   $host;


                proxy_set_header X-Real-IP      $remote_addr;


                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


            }


        }


本文出自 “10897714” 博客,请务必保留此出处http://10907714.blog.51cto.com/10897714/1733141

nginx负载均衡集群

原文:http://10907714.blog.51cto.com/10897714/1733141

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!