Nginx TCP长连接
1. 安装
支持nginx_tcp_proxy_module的nginx安装(1.9.9版本)
参考:https://blog.csdn.net/ting0fdnb/article/details/80496072
可使用编译
./configure --prefix=/usr/local/nginx --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-http_ssl_module --with-http_stub_status_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-http_flv_module --with-http_mp4_module --with-stream_ssl_module --with-http_realip_module --with-stream --add-module=../nginx-rtmp-module-master --add-module=../nginx_tcp_proxy_module-master
下载地址:https://files-cdn.cnblogs.com/files/dreasky/nginx_tcp.zip
2. 配置,保持连接配置
tcp { timeout 1d; proxy_read_timeout 10d; proxy_send_timeout 10d; proxy_connect_timeout 30; upstream tcpend { server 172.21.13.32:8999; check interval=60000 rise=2 fall=5 timeout=10000 type=tcp; } server { server_name 172.21.23.6; listen 172.21.23.6:8999; proxy_pass tcpend; so_keepalive on; tcp_nodelay on; } }
3. 查看状态
location /status { tcp_check_status; }