本文主要包含nginx tcp转发,nginx tcp 配置,nginx tcp,nginx tcp代理,nginx tcp nopush等服务器相关知识,网友希望可以进行参考
nginx TCP 转发配置
今天有客户需要增加移动线路,但机房刚好移动线路还没有开通,试用了一下转发。效果还不错
客户需求是 服务器只做TCP服务,对应的是7000 7001 7002 7003 转发
先在移动机房增加一台CENTOS 6.5 64位 服务器安装好NGINX等组件
最好是安装1.9版本以上的
配置nginx.conf 在最后添加如入:
stream {
upstream 7000 {hash $remote_addr consistent;
server 12.12.12.12:7000 max_fails=3 fail_timeout=30s;
}
upstream 7001 {
hash $remote_addr consistent;
server 12.12.12.12:7001 max_fails=3 fail_timeout=30s;
}
upstream 7002 {
hash $remote_addr consistent;
server 12.12.12.12:7002 max_fails=3 fail_timeout=30s;
}
upstream 7003 {
hash $remote_addr consistent;
server 12.12.12.12:7003 max_fails=3 fail_timeout=30s;
}
server {
listen 7000;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7000;
}
server {
listen 7001;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7001;
}
server {
listen 7002;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7002;
}
server {
listen 7003;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass 7003;
}
}
nginx 重启
#pkill -9 nginx 强行结束进程
#/usr/local/nginx/sbin/nginx 启动进程

