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。
安装:
http://nginx.org/download/nginx-1.7.2.tar.gz
https://github.com/yaoweibin/nginx_tcp_proxy_module/archive/master.zip
#cd nginx-1.7.2
#patch -p1 < /home/jfy/soft/nginx_tcp_proxy_module-master/tcp.patch
./configure --prefix=/usr/local/nginx \
--with-debug \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_image_filter_module \
--with-pcre=../pcre-8.21 \
--add-module=../ngx_devel_kit-0.2.19 \
--add-module=../lua-nginx-module-0.9.8 \
--add-module=../echo-nginx-module \
--add-module=../redis2-nginx-module \
--add-module=../set-misc-nginx-module \
--add-module=../nginx_http_push_module-0.692 \
--add-module=../nginx_tcp_proxy_module-master
tcp {
timeout 1d;
proxy_read_timeout 10d;
proxy_send_timeout 10d;
proxy_connect_timeout 30;
upstream ssh_116 {
# simple round-robin
server 172.16.18.116:2014;
check interval=3000 rise=2 fall=5 timeout=1000;
#check interval=3000 rise=2 fall=5 timeout=1000 type=ssl_hello;
#check interval=3000 rise=2 fall=5 timeout=1000 type=http;
#check_http_send "GET / HTTP/1.0\r\n\r\n";
#check_http_expect_alive http_2xx http_3xx;
}
server {
listen 8014;
proxy_pass ssh_116;
so_keepalive on;
tcp_nodelay on;
}
}