global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    stats socket /var/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

stats   uri     /status-admin  #haproxy 监控页面的访问地址
stats   auth    admin:adminpasswd
stats   hide-version
    retries 3
    #redispatch
    maxconn 5000
    timeout connect  5000
    timeout client  50000
    timeout server  50000

frontend            h5_f
    bind            *:80
    mode            http
    log             global
    use_backend     h5_server

frontend            h5_w
    bind            *:443
    mode            tcp 
    option          tcplog
    log             global
    use_backend     h5_four

backend h5_four
    mode            tcp
    balance         roundrobin
    server  h5_f1 10.29.25.11:443 weight 1 maxconn 10000 check inter 10s
    server  h5_f2 10.30.20.9:443 weight 1 maxconn 10000 check inter 10s

backend h5_server
    mode            http
    balance         roundrobin
    server  h5_one  10.29.25.11:80 weight 1 maxconn 10000 check inter 10s
    server  h5_tow  10.30.20.9:80 weight 1 maxconn 10000 check inter 10s

如果后端没有配置https则需要

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    stats socket /var/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

stats   uri     /status-admin  #haproxy 监控页面的访问地址
stats   auth    admin:adminpasswd
stats   hide-version
    retries 3
    #redispatch
    maxconn 5000
    timeout connect  5000
    timeout client  50000
    timeout server  50000

frontend            h5_f
    bind            *:80
    mode            http
    log             global
    use_backend     h5_server

frontend            h5_w
    bind            *:443 ssl crt /etc/haproxy/ckl.pem
    mode            http 
    log             global
    use_backend     h5_four

backend h5_four
    mode            http 
    balance         roundrobin
    server  h5_f1 10.29.25.11:443 weight 1 maxconn 10000 check inter 10s
    server  h5_f2 10.30.20.9:443 weight 1 maxconn 10000 check inter 10s

backend h5_server
    mode            http
    balance         roundrobin
    server  h5_one  10.29.25.11:80 weight 1 maxconn 10000 check inter 10s
    server  h5_tow  10.30.20.9:80 weight 1 maxconn 10000 check inter 10s

修正一下 增加 管理面板

原文地址https://blog.51cto.com/ckl893/1944926

最后修改:2021 年 06 月 14 日
如果觉得我的文章对你有用,请随意赞赏