# 安装nginx编译环境依赖yum -y install gcc gcc-c++ autoconf automakeyum -y install zlib zlib-devel openssl openssl-devel pcre-devel# 解压源码包tar -zxvf nginx-1.18.0.tar.gz# 进入目录cd nginx-1.18.0# 设置nginx编译安装配置,带上--with-stream./configure --prefix=/opt/nginx --sbin-path=/opt/nginx/sbin/nginx --conf-path=/opt/nginx/conf/nginx.conf --with-http_stub_status_module --with-http_gzip_static_module --with-stream# 编译make# 安装make install
vi /opt/nginx/conf/nginx.conf
stream {# 设置日志格式,其中proxy_protocol_addr为解析PP协议拿到的客户端地址, remote_addr为上一跳的地址log_format basic '$proxy_protocol_addr -$remote_addr [$time_local] ''$protocol $bytes_sent $bytes_received ''$session_time';access_log logs/stream.access.log basic;# upstream配置upstream RealServer {hash $remote_addr consistent;# 其中127.0.0.1:8888为业务服务器的地址和端口server 127.0.0.1:8888 max_fails=3 fail_timeout=30s;}# server配置server{# 四层监听端口,对应着四层代理配置的源站端口,需配置proxy_protocol支持对入包的PP协议解析listen 10000 proxy_protocol;proxy_connect_timeout 1s;proxy_timeout 3s;proxy_pass RealServer;}}
# 基于python2python2 -m SimpleHTTPServer 8888# 基于python3python3 -m http.server 8888
# 利用curl发起http请求, 其中域名为四层代理域名,8888为四层代理转发端口curl -i "http://d42f15b7a9b47488.davidjli.xyz.acc.edgeonedy1.com:8888/"
本页内容是否解决了您的问题?