nginx & tengine实现四层代理
Nginx默认是通过stream进行代理的,配置模板如下:
server {
listen 8014;
proxy_pass cnes2101;
proxy_timeout 60s;
}
upstream cnes2101{
server 10.0.10.1:2101;
}
tengine是通过nginx_tcp_proxy_module三方模块实现的:
参考链接:https://github.com/yaoweibin/nginx_tcp_proxy_module/
tcp {
upstream cluster {
# simple round-robin
server 192.168.0.1:80;
server 192.168.0.2:80;
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 8888;
...
proxy_pass cluster;
}
}