← ClaudeAtlas

load-balancerlisted

负载均衡配置
ryukyagamilight/terminal-skills · ★ 1 · AI & Automation · score 75
Install: claude install-skill ryukyagamilight/terminal-skills
# 负载均衡配置 ## 概述 HAProxy、Nginx LB、健康检查配置等技能。 ## HAProxy ### 安装与管理 ```bash # 安装 apt install haproxy # Debian/Ubuntu yum install haproxy # CentOS/RHEL # 服务管理 systemctl start haproxy systemctl enable haproxy systemctl reload haproxy # 检查配置 haproxy -c -f /etc/haproxy/haproxy.cfg ``` ### 基础配置 ```bash # /etc/haproxy/haproxy.cfg global log /dev/log local0 log /dev/log local1 notice chroot /var/lib/haproxy stats socket /run/haproxy/admin.sock mode 660 level admin stats timeout 30s user haproxy group haproxy daemon maxconn 4096 defaults log global mode http option httplog option dontlognull timeout connect 5000 timeout client 50000 timeout server 50000 errorfile 400 /etc/haproxy/errors/400.http errorfile 403 /etc/haproxy/errors/403.http errorfile 408 /etc/haproxy/errors/408.http errorfile 500 /etc/haproxy/errors/500.http errorfile 502 /etc/haproxy/errors/502.http errorfile 503 /etc/haproxy/errors/503.http errorfile 504 /etc/haproxy/errors/504.http ``` ### HTTP 负载均衡 ```bash frontend http_front bind *:80 default_backend http_back # ACL 规则 acl is_api path_beg /api use_backend api_back if is_api backend http_back balance roundrobin option httpchk GET /health http-check expect status 200 server web1 192.168.1.10:8080 check weight 3 server web2 192.168.1.11:8080 check weight 2 server web3 192.1