TypechoJoeTheme

主机评测

主机评测

专注云服务器评测和优惠码发布

nginx的tcp代理设置

2022-03-26
/
0 评论
/
692 阅读
/
正在检测是否收录...
03/26

[root@locahost ~]# yum install gcc gcc-c++ automake pcre pcre-devel zlip zlib-devel openssl openssl-devel -y
[root@locahost ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz
[root@locahost ~]# tar xf nginx-1.12.2.tar.gz
[root@locahost ~]# cd nginx-1.12.2
[root@locahost nginx-1.12.2]# ./configure --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --without-http
[root@locahost nginx-1.12.2]# make && make install

配置nginx.conf

[root@locahost nginx-1.12.2]# cd /usr/local/nginx/conf/
[root@locahost conf]# cp nginx.conf{,.bak}
[root@locahost conf]# vi nginx.conf

worker_processes auto;
error_log /usr/local/nginx/logs/error.log info;
events {
    worker_connections  1024;
}
stream {
    upstream web {
        server 111.1.1.2:80; # 注:这里是真实服务器源IP
    }
    server {
        listen 0.0.0.0:80;  
        proxy_timeout 20s;
        proxy_pass web;
    }
}

启动nginx

[root@locahost conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@locahost conf]# /usr/local/nginx/sbin/nginx -s reload

参考 https://nginx.org/en/docs/stream/ngx_stream_core_module.html

Nginx
朗读
赞 · 0
赞赏
感谢您的支持,我会继续努力哒!

三合一收款

下面三种方式都支持哦

微信
QQ
支付宝
打开支付宝/微信/QQ扫一扫,即可进行扫码打赏哦
版权属于:

主机评测

本文链接:

https://zjpc.cc/1081.html(转载时请注明本文出处及文章链接)

评论 (0)