Skip to content

Instantly share code, notes, and snippets.

@rds13
Created January 31, 2014 16:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rds13/8735677 to your computer and use it in GitHub Desktop.
Save rds13/8735677 to your computer and use it in GitHub Desktop.
# see https://github.com/postrank-labs/goliath/wiki/HAProxy
global
pidfile /var/run/haproxy.pid
log 127.0.0.1 local0 info
maxconn 64000
defaults
clitimeout 60000 # maximum inactivity time on the client side
srvtimeout 60000 # maximum inactivity time on the server side
timeout connect 8000 # maximum time to wait for a connection attempt to a server to succeed
stats enable
stats auth admin:password
stats uri /monitor
stats refresh 5s
option httpchk GET /
retries 5
option redispatch
# errorfile 503 /path/to/503.text.file
balance roundrobin # each server is used in turns, according to assigned weight
frontend http
bind :80
mode http
monitor-uri /haproxy # end point to monitor HAProxy status (returns 200)
default_backend servers
frontend tcp
bind :9000
option tcplog
option contstats
default_backend tcpservers
backend tcpservers
balance leastconn
server tcp1 192.168.22.6 check port 7070 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
server tcp2 192.168.22.7 check port 7070 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
server tcp3 192.168.22.9 check port 7070 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
# http://www.tokiwinter.com/highly-available-load-balancing-of-apache-tomcat-using-haproxy-stunnel-and-keepalived/
backend servers
option httpchk OPTIONS /
option forwardfor
option http-server-close
appsession JSESSIONID len 52 timeout 3h
# option httpclose
### server srv0 ${IP}:${PORT} weight 1 maxconn 100 check inter 4000
@twillouer
Copy link

cat /etc/haproxy/haproxy.cfg 
global
        log /dev/log    local0
#       log /dev/log    local1 notice
#      log 127.0.0.1 local3 debug
        chroot /var/lib/haproxy
        user haproxy
        group haproxy
        daemon
      stats socket /var/lib/haproxy.socket user dw mode 660
      maxconn     24000

defaults
        log     global
        contimeout 5000
      maxconn     24000

    clitimeout 60000 # maximum inactivity time on the client side
    srvtimeout 60000 # maximum inactivity time on the server side
    timeout connect 8000 # maximum time to wait for a connection attempt to a server to succeed

listen http 
    bind 127.0.0.1:8000
    mode http
    option httplog
    stats enable
    stats auth admin:password
    stats uri /monitor
    stats refresh 5s
    #option httpchk GET /

    server http1 10.20.56.50
      maxconn     24000

frontend tcp
    bind :17070
    option tcplog
    option  contstats
    default_backend tcpservers
      maxconn     24000

backend tcpservers
    #balance leastconn
    balance roundrobin
    server tcp1 10.20.56.50:17078 check port 17078 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp2 10.20.56.50:17079 check port 17079 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp3 10.20.56.50:17080 check port 17080 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp4 10.20.56.50:17081 check port 17081 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp5 10.20.56.50:17082 check port 17082 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp6 10.20.56.50:17083 check port 17083 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp7 10.20.56.50:17084 check port 17084 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp8 10.20.56.50:17085 check port 17085 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp9 10.20.56.50:17086 check port 17086 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000
    server tcp10 10.20.56.50:17087 check port 17087 inter 60s rise 2 fall 10 fastinter 1s maxconn 5000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment