windows nginx TCP代理 负载均衡

版权声明:版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_41054313/article/details/88663765

必须是 nginx-1.9.0 以上版本(包括1.9.0)。该版本之后,增加了  stream module,可以实现该功能。

下载地址:http://nginx.org/download/nginx-1.9.9.zip    http://nginx.org/download/

安装目录:

修改nginx-1.9.0解压安装目录下conf/下的nginx.conf 文件。

修改配置如下形式:

http{
    ...
}

stream{
    upstream tcp{
        server 192.168.101.17:5555 weight=1;#负载均衡的主机IP与端口 weight权重 代表分到资源的比例
        server 192.168.101.18:5555 weight=1;
    }    
    server{
        #listen [::1]:7777  #IPV6
        listen 7777;#监听本机端口号IPV4

        proxy_pass tcp;
    }
}

测试:

使用测试工具连接本机的 7777端口 在192.168.101.17:5555上接收到数据

测试工具下载地址:

链接:https://pan.baidu.com/s/1tWfJRP9dewdUU8m0sldbEw 
提取码:bwuy 

 

猜你喜欢

转载自blog.csdn.net/qq_41054313/article/details/88663765