NGINX负载均衡代码

图片[1]-NGINX负载均衡代码-〈Destiny宿命〉

中转的一种方式

升级系统

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;
    }
}
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容