码迷,mamicode.com
首页 > 其他好文 > 详细

nginx实现openfire负载均衡

时间:2016-09-30 20:41:09      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

Nginx版本必须是1.9以上,不然不支持tcp连接,要么加入其他插件

在nginx.conf文件中加入下图中的代码,图中的ip与端口配成自己的,配置好后,客户端请求listen监听的端口,ip为nginx所在服务器的地址,openfire服务器名称在集群中是一样的。例如我测试配置的:

Nginx所在服务地址:http://192.168.1.248

Listen监听端口:6222

Openfire服务器名称:test

 

 

stream {       

      upstream openfire5222 {                       

                hash $remote_addr consistent;                               

                server 192.168.1.249:5222 weight=5;                                                       

                server 192.168.1.248:5222 weight=5;             

        }       

        server {                       

            listen 6222;                               

            proxy_connect_timeout 10s; #设置连接超时时长  必须                         

            proxy_timeout 30s;  #设置代理超时时长          必须                   

            proxy_pass openfire5222;               

        }

}

nginx实现openfire负载均衡

标签:

原文地址:http://www.cnblogs.com/shihaiming/p/5924536.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!