负载均衡后端状态
状态 | 概述 |
---|---|
down | 当前的server暂时不参与负载均衡 |
backup | 预留的备份服务器 |
max_fails | 允许请求失败的次数 |
fail_timeout | 经过max_fails失败后, 服务暂停时间 |
max_conns | 限制最大的接收连接数 |
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80 down;
server 172.16.1.8:80;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80;
server 172.16.1.8:80;
server 172.16.1.10:80 backup;
server 172.16.1.11:80 backup;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80 max_fails=3 fail_timeout=10s;
server 172.16.1.8:80;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}
[root@lb01 ~]# vim /etc/nginx/conf.d/zh.conf
upstream zh {
server 172.16.1.7:80 max_conns=10;
server 172.16.1.8:80;
}
server {
listen 80;
server_name linux.zh.com;
location / {
proxy_pass http://zh;
include /etc/nginx/proxy_params;
}
}
本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13596100.html