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