Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
haproxytechblog / blog20181001-01.cfg
Last active June 18, 2022 21:32
Using HAProxy as an API Gateway, Part 1
frontend api_gateway
bind :443 ssl crt /etc/hapee-1.8/certs/cert.pem
acl PATH_cart path_beg -i /cart
acl PATH_catalog path_beg -i /catalog
use_backend be_cart if PATH_cart
use_backend be_catalog if PATH_catalog
backend be_cart
server s1 10.0.0.3:80
@haproxytechblog
haproxytechblog / blog20180921-01.cfg
Last active November 28, 2022 16:27
Introduction to HAProxy Stick Tables
backend webfarm
stick-table type ip size 1m expire 10s store http_req_rate(10s)
# other configuration...
@haproxytechblog
haproxytechblog / blog20180913-01.cfg
Last active June 14, 2022 14:21
Introduction to HAProxy ACLs
acl is_static path -i -m beg /static/
@haproxytechblog
haproxytechblog / blog20181009-01.sh
Last active April 25, 2019 13:43
HAProxy on AWS: Best Practices Part 2
export AWS_ACCESS_KEY_ID=[YOUR ACCESS KEY]
export AWS_SECRET_ACCESS_KEY=[YOUR SECRET ACCESS KEY]
terraform init
terraform apply -auto-approve
@haproxytechblog
haproxytechblog / blog20181017-01.map
Last active August 21, 2023 15:42
Introduction to HAProxy Maps
# A comment begins with a hash sign
static.example.com be_static
www.example.com be_static
# You can add additional comments, but they must be on a new line
example.com be_static
api.example.com be_api
@haproxytechblog
haproxytechblog / blog20181024-01.sh
Last active August 3, 2023 17:56
The Four Essential Sections of an HAProxy Configuration
haproxy -c -f /etc/hapee-1.8/hapee-lb.cfg
@haproxytechblog
haproxytechblog / blog20181109-01.cfg
Last active May 8, 2024 16:24
Application-Layer DDoS Attack Protection with HAProxy
backend per_ip_rates
stick-table type ip size 1m expire 10m store http_req_rate(10s)
@haproxytechblog
haproxytechblog / blog20180531-01.sh
Last active November 20, 2018 01:47
Hitless Reloads with HAProxy – HOWTO
stats socket /var/run/haproxy.sock mode 600 expose-fd listeners level user
@haproxytechblog
haproxytechblog / blog20180524-01.cfg
Last active January 8, 2022 17:22
Let’s Encrypt (ACMEv2) for HAProxy
global
log /dev/log local0 debug
nbproc 1
daemon
lua-load config.lua
lua-load acme.lua
defaults
log global
mode http
@haproxytechblog
haproxytechblog / blog20180405-01.sh
Last active January 29, 2021 14:35
HAProxy and Consul with DNS for Service Discovery
consul agent -server -ui -bootstrap-expect=1 -data-dir=/var/lib/consul \
-node=server -bind=0.0.0.0 -config-dir=/etc/consul.d -client=0.0.0.0 \
-http-port=80 -domain=consul.itchy.local