nginx配置tcp端口转发

1、安装nginx,网上搜一大堆,不赘述。

2、启用stream

   cd nginx-1.9.9

   ./configure --with-stream

   make & make install

   ps -ef|grep nginx

   kill -QUIT (master对应的进程号)

   ./nginx

3、配置tcp端口映射

events {
worker_connections 1024;
}
stream {

upstream tcpLink {

hash $remote_addr consistent;

server 122.112.209.30:9299 weight=5 max_fails=3 fail_timeout=30s;
}

server {

listen 9900;

proxy_connect_timeout 1s;

proxy_timeout 3s;

proxy_pass tcpLink;

}

upstream tcpLink1 {

hash $remote_addr consistent;

server 122.112.177.145:9099 weight=5 max_fails=3 fail_timeout=30s;
}

server {

listen 9911;

proxy_connect_timeout 1s;

proxy_timeout 3s;

proxy_pass tcpLink1;

}
}
http {
include mime.types;
default_type application/octet-stream;
}

4、重启nginx

posted @ 2020-01-06 15:27  前度刘郎  阅读(8412)  评论(0编辑  收藏  举报
欢迎来到戴建伟的博客!