HAProxy
约 2 分钟阅读
- haproxy.com链接www.haproxy.comhaproxy.com - The #1 Open Source Software Load Balancer and Application Delivery Controller · haproxy/haproxy · 最擅长 负载均衡笔记:HAProxy - The #1 Open Source Software Load Balancer and Application Delivery Controller
- haproxy/haproxyGitHubhaproxy/haproxyhaproxy.com - The #1 Open Source Software Load Balancer and Application Delivery Controller · haproxy/haproxy · 最擅长 负载均衡笔记:HAProxy
- 最擅长 负载均衡
- 特性
- L4(TCP) L7(HTTP) 负载均衡
- URL 重写
- 限流
- SSL/TLS termination/offload
- Gzip
- 支持 HTTP 代理协议
- 监控检查
- 链接和 HTTP 日志
- HTTP/2
- 多线程
- 无缝重载
- gRPC
- Lua 和 SPOE 支持
- L4 重试
- 简单熔断机制
- 参考
- HAproxy Starter Guide
- HAProxy at GitHub
- 5 Ways to Extend HAProxy with Lua
- Using HAProxy as an API Gateway
- haproxytech/client-nativeGitHubhaproxytech/client-native
- Go client for HAProxy configuration and runtime API
- 配置模型 modelsGitHub 文件haproxytech/client-native/models
- roxy-wi/roxy-wiGitHubroxy-wi/roxy-wi
- Apache-2.0, Python
- Roxy-WI is a web interface for managing Haproxy, Nginx, Apache and Keepalived
- 不能转发任意 UDP - Nginx 可以
- 2.3+ 支持 syslog UDP
- 2.5+ 支持 QUIC, HTTP/3
- 未来可能支持 DNS
haproxy -c -f haproxy.cfg # 检查配置是否正确
haproxy -f haproxy.cfg # 启动
# master-worker mode - reload
# 本质也是 -sf 启新的进程
kill -USR2 $(cat /var/run/haproxy.pid)
# 重启新的 haproxy - reload
haproxy -D -f /etc/haproxy/haproxy.cfg -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid)docker run --rm -it \
-v /path/to/etc/haproxy:/usr/local/etc/haproxy:ro \
--sysctl net.ipv4.ip_unprivileged_port_start=0 \
--name haproxy haproxy:2.5
# reload
docker kill -s HUP haproxymetrics
- www.haproxy.com/blog/haproxy-exposes-a-prometheus-metrics-endpoint
- www.haproxy.com/blog/exploring-the-haproxy-stats-page
Runtime API
global
stats socket [email protected]:9999 level admin
stats socket /run/haproxy-runtime-api.sock mode 666 level admin
stats timeout 2mecho "help" | socat stdio tcp4-connect:127.0.0.1:9999
echo "show acl" | socat stdio /run/haproxy-runtime-api.sock
socat readline /run/haproxy-runtime-api.sock
helpConnect() failed for backend : no free ports
cat /proc/sys/net/ipv4/ip_local_port_range
echo "2000 60999" | sudo tee /proc/sys/net/ipv4/ip_local_port_range- 尝试添加
resolve-prefer ipv4
关联信息
反向链接、本文链接的其他页面和外部资料。
参考资料
GitHub4 条
- haproxy/haproxygithub.com/haproxy/haproxy
- haproxytech/client-nativegithub.com/haproxytech/client-native
- haproxytech/client-native/modelsgithub.com/haproxytech/client-native/tree/master/models
- roxy-wi/roxy-wigithub.com/roxy-wi/roxy-wi
其他外链7 条
- cbonte.github.io/haproxy-dconv/2.3/intro.htmlcbonte.github.io/haproxy-dconv/2.3/intro.html
- www.haproxy.comwww.haproxy.com/
- www.haproxy.com/blog/5-ways-to-extend-haproxy-with-luawww.haproxy.com/blog/5-ways-to-extend-haproxy-with-lua
- www.haproxy.com/blog/exploring-the-haproxy-stats-pagewww.haproxy.com/blog/exploring-the-haproxy-stats-page
- www.haproxy.com/blog/haproxy-exposes-a-prometheus-metrics-endpointwww.haproxy.com/blog/haproxy-exposes-a-prometheus-metrics-endpoint
- www.haproxy.com/blog/using-haproxy-as-an-api-gateway-part-3-health-checkswww.haproxy.com/blog/using-haproxy-as-an-api-gateway-part-3-health-checks
- www.haproxy.com/user-spotlight-series/inside-the-github-load-balancerwww.haproxy.com/user-spotlight-series/inside-the-github-load-balancer