openfire集群+nginx负载均衡
2016-08-31 16:44
621 查看
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 地址:
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登录均可。
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.ziptar -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登录均可。
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- Nginx 学习笔记(一)
- 网站502与504错误分析
- 用zabbix监控nginx_status状态
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 把Lua编译进nginx步骤方法
- web 应用中常用的各种 cache详解
- Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略
- window+nginx+php环境配置 附配置搭配说明
- 解析CI即CodeIgniter框架在Nginx下的重写规则
- 将PHP从5.3.28升级到5.3.29时Nginx出现502错误
- 基于Nginx0.8.54+PHP5.3.4+MySQL5.5.8的全新LNMP稳定版架构搭建的VPS