负载均衡结合项目

1.配置wecenter的负载均衡


[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf 
upstream zh {
    server 172.16.1.7:80;
    server 172.16.1.9:80;
}

server {
    listen 80;
    server_name linux.zh.com;

    location / {
        proxy_pass http://zh;
        include /etc/nginx/proxy_params;
    }
}

#配置hosts,访问测试
10.0.0.5 linux.zh.com

2.负载均衡常见错误

1)错误

如果后端服务器返回报错,负载均衡仍然会将请求分配到出错的web服务器,因为负载均衡只会根据调度算法将请求分配到后端,不会进行判断后端是否正常

2)解决错误的模块语法

Syntax:	proxy_next_upstream error | timeout | invalid_header | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | http_429 | non_idempotent | off ...;
Default:	proxy_next_upstream error timeout;
Context:	http, server, location

3)配置方法

[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf 
upstream zh {
    server 172.16.1.7:80;
    server 172.16.1.9:80;
}

server {
    listen 80;
    server_name linux.zh.com;

    location / {
        proxy_pass http://zh;
        include /etc/nginx/proxy_params;
        proxy_next_upstream http_502 error timeout;
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值