Skip to content

Instantly share code, notes, and snippets.

@devfred
Forked from patmandenver/haproxy.cfg
Created November 16, 2016 07:32
Show Gist options
  • Save devfred/aab59c5e25105dd14860b91ba1d15f4e to your computer and use it in GitHub Desktop.
Save devfred/aab59c5e25105dd14860b91ba1d15f4e to your computer and use it in GitHub Desktop.
haproxy with letsencrypt forwarding
global
log 127.0.0.1 syslog
maxconn 1000
user haproxy
group haproxy
daemon
defaults
log global
mode http
option httplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
option contstats
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout check 10s
###########################################
#
# HAProxy Stats page
#
###########################################
listen stats
bind *:9090
mode http
maxconn 10
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /
stats auth admin:admin
###########################################
#
# Front end for all
#
###########################################
frontend ALL
bind *:80
mode http
# Define path for lets encrypt
acl is_letsencrypt path_beg -i /.well-known/acme-challenge/
use_backend letsencrypt if is_letsencrypt
# Define hosts
acl host_foo hdr(host) -i foo.test.10x13.com
acl host_bar hdr(host) -i bar.test.10x13.com
# Direct hosts to backend
use_backend foo if host_foo
use_backend bar if host_bar
###########################################
#
# Back end letsencrypt
#
###########################################
backend letsencrypt
server letsencrypt 127.0.0.1:8888
###########################################
#
# Back end for foo
#
###########################################
backend foo
balance roundrobin
option httpchk GET /check
http-check expect rstring ^UP$
default-server inter 3s fall 3 rise 2
server server1 192.168.0.10:8080 check
server server2 192.168.0.11:8080 check
###########################################
#
# Back end for bar
#
###########################################
backend bar
balance roundrobin
option httpchk GET /check
http-check expect rstring ^UP$
default-server inter 3s fall 3 rise 2
server server1 192.168.0.12:8080 check
server server2 192.168.0.13:8080 check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment