Skip to content

Instantly share code, notes, and snippets.

@adamgins
Created March 11, 2015 21:47
Show Gist options
  • Select an option

  • Save adamgins/740a03dfc65424431a62 to your computer and use it in GitHub Desktop.

Select an option

Save adamgins/740a03dfc65424431a62 to your computer and use it in GitHub Desktop.
haproxy.cfg
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 80000
#debug
#quiet
user haproxy
group haproxy
stats socket /tmp/haproxy.sock
defaults
log global
mode http
option httplog
option dontlognull
retries 3
option redispatch
maxconn 80000
timeout client 60s # Client and server timeout must match the longest
timeout server 60s # time we may wait for a response from the server.
timeout queue 120s # Don't queue requests too long if saturated.
timeout connect 10s # There's no reason to change this one.
timeout http-request 30s # A complete request may never take that long.
option httpclose # disable keepalive (HAProxy does not yet support the HTTP keep-alive mode)
option abortonclose # enable early dropping of aborted requests from pending queue
option httpchk # enable HTTP protocol to check on servers health
stats auth opsworks:<SOME CODE>
stats uri /haproxy?stats
# Set up application listeners here.
backend nodejs_app_servers
balance roundrobin
option redispatch
option forwardfor
option httpchk OPTIONS /
server nodejs-app1 SOME_IP:80 weight 4 maxconn 40 check inter 10s
backend nodejs_app_servers_ssl
mode tcp
balance roundrobin
option redispatch
option ssl-hello-chk
server nodejs-app1 SOME_IP:443 weight 4 maxconn 40 check inter 10s
frontend http-in
bind :80
# all domains of Rails applications
# all domains of PHP applications
# all domains of node.js applications
acl nodejs_application_buzzy_domain_buzzy hdr_end(host) -i buzzy
# all domains of static applications
# choose backend
use_backend nodejs_app_servers if nodejs_application_buzzy_domain_buzzy
default_backend nodejs_app_servers
frontend https-in
mode tcp
bind :443
# all domains of Rails applications
# all domains of PHP applications
# all domains of node.js applications
acl nodejs_applications_ssl hdr_end(host) -i buzzy
# all domains of static applications
use_backend nodejs_app_servers_ssl if nodejs_applications_ssl
default_backend nodejs_app_servers_ssl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment