标签:nginx代理tcp端口
cd /usr/local/src/wget https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
unzip master
wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gz
tar zxvf tengine-2.1.0.tar.gz
cd tengine-2.1.0
yum install patch
patch -p1 </usr/local/src/nginx_tcp_proxy_module-master/tcp.patch
./configure --prefix=/usr/local/nginx_mysql --add-module=/usr/local/src/nginx_tcp_proxy_module-master/
make && make install
vi /usr/local/nginx_mysql/conf/nginx.conf
tcp {
upstream proxy_name {
# simple round-robin
server 192.168.1.10:8000;
server 192.168.1.10:8001;
server 192.168.1.11:8000;
server 192.168.1.11:8001;
check interval=3000 rise=2 fall=5timeout=1000;
#check interval=3000 rise=2 fall=5timeout=1000
#check interval=3000 rise=2 fall=5timeout=1000
#check_http_send "GET /HTTP/1.0rnrn";
#check_http_expect_alive http_2xxhttp_3xx;
}
server {
listen 8888;
proxy_pass proxy_name;
}
}
说明:
check interval 健康检查,单位是毫秒
rise 检查几次正常后,将reslserver加入以负载列表中
fall 检查几次失败后,摘除realserver
timeout 检查超时时间,单位许毫秒
具体可查看nginx_tcp_proxy_module-master/README,很详细。
###模块指令是TCP,它是不属于HTTP框架内的,所以和HTTP{}同级别。###
tcp {
upstream proxy_name {
server 192.168.1.10:3306;
}
server {
listen 3306;
proxy_pass proxy_name;
}
}
标签:nginx代理tcp端口
原文地址:http://blog.51cto.com/10956218/2095685