首页 > 其他 > 详细

nginx配置tcp端口转发

时间:2020-01-06 16:43:02      阅读:530      评论:0      收藏:0      [点我收藏+]

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

nginx配置tcp端口转发

原文:https://www.cnblogs.com/jianwei-dai/p/12156544.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!