对比
可打开四层
不支持正则
高可用 nginx + keeplived lvs +keeplived
代理软件 nginx,haproxy
性能 LVS>Haproxy>nginx 功能 nginx>Haproxy>LVS
F5 big-ip
https://blog.csdn.net/weixin_46575696/article/details/109638521
配置文件
[root@proxy ~]
global
log 127.0.0.1 local2
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
daemon
defaults
mode http
option dontlognull
option httpclose
option httplog
option redispatch
timeout client 300000
timeout server 300000
maxconn 3000
retries 3
格式1
frontend main
bind *:5000
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
backend static
balance roundrobin
server static 127.0.0.1:4331 check
backend app
balance roundrobin
server app1 127.0.0.1:5001 check
server app2 127.0.0.1:5002 check
server app3 127.0.0.1:5003 check
server app4 127.0.0.1:5004 check
格式2
listen 名称 *:80
balance roundrobin
server web1
server web2
案例
listen websrv-rewrite 0.0.0.0:80
balance roundrobin
server web1 192.168.2.100:80 check inter 2000 rise 2 fall 5
server web2 192.168.2.200:80 check inter 2000 rise 2 fall 5
frontend haproxy_in
bind *:80
default_backend haproxy_http
backend haproxy_http
balance roundrobin
mode http
server web1 192.168.222.130:80
server web2 192.168.222.131:80
健康检查
listen status
bind 0.0.0.0:1080
mode http
stats enable
stats refresh 5
stats realm Haproxy\ status
stats uri /admin?stats
stats auth admin:admin
stats hide-version
listen stats *:1080
stats refresh 30s
stats uri /stats
stats realm Haproxy Manager
stats auth admin:admin
|