nginx tcp负载均衡配置

1. nginx从1.9.0后引入模块ngx_stream_core_module,模块是没有编译的,需要用到编译需添加--with-stream配置参数

2. 在 nginx.conf 文件中,

与events 和 http 同级:

添加以下配置:

stream {
upstream sockettcp{
#hash $remote_addr consistent;
#server 39.xx.xx.xx:8000;
server 192.xx.xx.xx:8000;
server 39.xx.xx.xx:8000;
}

server{
listen 8000;
proxy_connect_timeout 5s;
proxy_timeout 5s;
proxy_pass sockettcp;
}

}

猜你喜欢

转载自www.cnblogs.com/maohuidong/p/9426223.html