nginx TCP转发配置

nginx1.90对TCP协议的代理并不是默认开启的,需要在编译的时候配置 --with-stream 参数

进入原有nginx源码目录

  1. ./configure --prefix=/usr/local/nginx  --with-stream
  2. make  
  3. make install  

配置nginx

conf/nginx.conf

  1. stream {
        upstream proxy_card {
            # simple round-robin  转发IP和端口
            server 192.168.1.12:12340;
            server 192.168.1.13:12340;
            #check interval=3000 rise=2 fall=5 timeout=1000;
            #check interval=3000 rise=2 fall=5timeout=1000
            #check interval=3000 rise=2 fall=5timeout=1000
            #check_http_send "GET /HTTP/1.0\r\n\r\n";
            #check_http_expect_alive http_2xxhttp_3xx;
        }
        server {
            listen 12340; #监听端口
            proxy_pass proxy_card;  #转发请求
        }
    }

你可能感兴趣的:(中间件)