openfire有通过tcp端口通讯,因此nginx需要额外安装nginx_tcp_proxy_module.
nginx tcp代理功能由nginx_tcp_proxy_module模块提供,同时监测后端主机状态。该模块包括的模块有: ngx_tcp_module, ngx_tcp_core_module, ngx_tcp_upstream_module, ngx_tcp_proxy_module, ngx_tcp_upstream_ip_hash_module。
安装:
使用nginx最新版nginx-1-10.1.tar.gz
下载nginx_tcp_proxy_module 地址:
https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
tar -xzvf nginx-1.10.1.tar.gz
cd nginx-1.10.1
patch -p1 < /root/nginx_tcp_proxy_module-master/tcp.patch 打补丁
./configure --prefix=/usr/local/nginx --add-module=/root/nginx_tcp_proxy_module-master 编译
make&make install
nginx 配置文件:
# vim /etc/nginx/nginx.conf
tcp { //添加
timeout 1d;
proxy_read_timeout 10d;
proxy_send_timeout 10d;
proxy_connect_timeout 30;
upstream openfire5222{
server 192.168.253.150:5222;
server 192.168.253.151:5222;
check interval=3000 rise=2 fall=5 timeout=1000;
}
server{
listen 6222; nginx安装在192.168.253.151上面 所以这里的端口不能跟151上面的端口重复
proxy_pass openfire5222;
so_keepalive on;
tcp_nodelay on;
}
upstream openfire5223{
server 192.168.253.150:5222;
server 192.168.253.151:5222;
check interval=3000 rise=2 fall=5 timeout=1000;
}
server{
listen 6223;
proxy_pass openfire5223;
so_keepalive on;
tcp_nodelay on;
}
}
http{ //添加以下内容
。。。。。。。。。。。。省略。。。。。。。。。。。。。。
upstream openfire7070{
server 192.168.253.151:7070;
server 192.168.253.150:7070;
}
server{
listen 17070;
server_name 192.168.253.151;
location / {
proxy_pass http://openfire7070;
}
}
upstream openfire9090{
server 192.168.253.150:9090;
server 192.168.253.151:9090;
ip_hash;
}
server {
listen 19090;
server_name 192.168.253.151;
location / {
proxy_pass http://openfire9090;
}
}
启动nginx。
登录192.168.253.151:19090查看,
或者用客户端spark登录均可。
本文出自 “梦想照进现实” 博客,请务必保留此出处http://lookingdream.blog.51cto.com/5177800/1844829
原文地址:http://lookingdream.blog.51cto.com/5177800/1844829