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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM