nginx1.16 4 Layer Proxy Binding port section

Demand:
A host (192.168.5.2) to the host network through the B, B to C the host (172.18.4.15) through the network, access from the A port 30000-31000 C

1. Modify the program on the B iptables, failure, not understood.

2. program on B openresty, 4-layer proxy configuration, port 30,000 successful test
stream listen port can support segment, the format xxx-xxx, but later versions require 1.15.10
latest openresty is 1.15.8.1, based on nginx 1.15.8 core, are not supported. I can only re-install a nginx

Source Installation 1.16.0 nginx

mkdir /home/nginx
cd /home/nginx

// 下载最新版本 nginx-1.16.0.tar.gz,解压,重命名为nginx-1.16.0-src
wget https://nginx.org/download/nginx-1.16.0.tar.gz
tar -zxf nginx-1.16.0.tar.gz
mv nginx-1.16.0 nginx-1.16.0-src

// 下载依赖的pcre(rewrite模板依赖)pcre-8.43.tar.gz  和 zlib (gzip依赖)zlib-1.2.11.tar.gz, 解压
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar zxf pcre-8.43.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
tar zxf zlib-1.2.11.tar.gz

cd nginx-1.16.0-src
./configure --prefix=/home/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-stream --with-debug --with-pcre=../pcre-8.43 --with-zlib=../zlib-1.2.11c

make && make install

./sbin/nginx 启动

Edit conf / nginx.conf

stream {
  server {
     allow 192.168.5.2;
     listen 30000-31000;
     proxy_pass 172.18.4.15:$proxy_port;
  }
}

Restart nginx

./sbin/nginx -t
./sbin/nginx -s reload

Reproduced in: https: //www.jianshu.com/p/10a7761597b9

Guess you like

Origin blog.csdn.net/weixin_34372728/article/details/91258030