使用Nginx转发tcp请求--四层透明代理
要求nginx版本大于1.9,
在nginx.conf添加以下,要求和http{}同级
worker_processes 6;
events { worker_connections 1024; }
stream { upstream cakehouse { server 172.17.210.101:10001 weight=5 max_fails=2 fail_timeout=30s ; } server { listen 8888; proxy_connect_timeout 10s; proxy_timeout 5s; proxy_pass cakehouse; } }
前提编译时需要加载--with-stream模块
# ./configure --with-stream