首页 > 其他 > 详细

nginx配置负载均衡

时间:2020-04-19 20:59:38      阅读:51      评论:0      收藏:0      [点我收藏+]

在nginx 目录下打开 nginx.conf

在http {

下修改 增加:

upstream redislock{
        server 192.168.0.106:8001 weight=1; // 自己部署到服务地址和端口
        server 192.168.0.106:8002 weight=1; // 自己部署到服务地址和端口
}

location / {
            root   html;
            index  index.html index.htm;
            proxy_pass   http://redislock;
        }
 
如下所示:
upstream redislock{
        server 192.168.0.106:8001 weight=1;
        server 192.168.0.106:8002 weight=1;
    }


    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass   http://redislock;
        }

 

访问:127.0.0.1:80  会轮询请求到服务 

192.168.0.106:8001
192.168.0.106:8002

 

nginx配置负载均衡

原文:https://www.cnblogs.com/wanjun-top/p/12732888.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!