Skip to content

Instantly share code, notes, and snippets.

@Tokugero
Created January 8, 2019 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tokugero/ae0a459ae8fe3c3baa5e0a08c3654dab to your computer and use it in GitHub Desktop.
Save Tokugero/ae0a459ae8fe3c3baa5e0a08c3654dab to your computer and use it in GitHub Desktop.
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
# An alternative list with additional directives can be obtained from
# https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
frontend http-in
bind *:80
#letsencrypt ssl stuff
bind *:443 ssl crt /etc/ssl/<my domain>/<my domain>.pem crt /etc/ssl/<my domain>-0001/<my domain>-0001.pem
redirect scheme https code 301 if !{ ssl_fc }
acl letsencrypt-acl path_beg /.well-known/acme-challenge/
use_backend letsencrypt-backend if letsencrypt-acl
#Header forwarders
reqadd X-Forwarded-Proto:\ https
reqadd X-Forwarded-Ssl:\ on
# Define hosts
acl host_dubweb hdr(host) -i dubweb.<my domain>
acl host_webserver hdr(host) -i <my domain>
## figure out which on to use
use_backend dubweb_cluster if host_dubweb
use_backend webserver if host_webserver
backend dubweb_cluster
balance leastconn
option httpclose
option forwardfor
cookie JSESSIONID prefix
server dubweb1 dubweb:8000 cookie A check
backend letsencrypt-backend
server letsencrypt 127.0.0.1:8888
#Fallback
backend webserver
balance leastconn
option httpclose
option forwardfor
cookie JSESSIONID prefix
server webserver1 webserver:80 cookie A check
#Monitoring
listen stats
bind :1936
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /haproxy?stats
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment