NGINX负载均衡代码
我的教程
NGINX负载均衡代码

中转的一种方式

google

升级系统

centos

yum update

debian

apt-get update

下载nginx源(centos)

rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

安装(centos)

yum install nginx -y

(debian)

apt-get install nginx -y

运行nginx
(centos)

systemctl start nginx.service

(debian)

service nginx start
mkdir -p /etc/nginx/tcpconf.d

vi /etc/nginx/tcpconf.d/ssrproxy.conf

echo "include /etc/nginx/tcpconf.d/*.conf;" >> /etc/nginx/nginx.conf

关闭防火墙

systemctl stop firewalld.service 

开机禁止启动防火墙

systemctl disable firewalld.service

编辑

vi /etc/nginx/tcpconf.d/ssrproxy.conf

重启

systemctl restart nginx

service nginx restart

date

开机启动

systemctl enable nginx.service

定时任务

crontab -e

0 */6 * * * systemctl restart nginx
stream {
    upstream hk {
        server 2222:42194;
        server 3333:55689;
        server 44444:55866;
        server 55555:44562;
    }
    server {
        listen 11040;
        listen 11040 udp;
        proxy_pass hk;
    }
}

相关导航