nginx做TCP代理实现群集

nginx做TCP代理实现群集

nginx从版本1.9开始,既能做HTTP代理,又能做TCP代理,这就非常完美了。

配置nginx.conf。

在Nginx配置文件(nginx.conf)中最下面添加配置 ,并保存退出

            与配置文件中的server并列

stream {
    upstream proxy_card {
        # simple round-robin  转发IP和端口
        server 192.168.1.200:9092;
        #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

";
        #check_http_expect_alive http_2xxhttp_3xx;
    }
    server {
        listen 12340; #监听端口
        proxy_pass proxy_card;  #转发请求
    }
}
原文地址:https://www.cnblogs.com/Thenext/p/11953246.html