Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
haproxytechblog / blog20220729-01.cfg
Created July 29, 2022 15:11
Log Forwarding with HAProxy and Syslog
log-forward syslog
# Accepts incoming TCP messages
bind 0.0.0.0:514
# Accepts incoming UDP messages
dgram-bind 0.0.0.0:514
# Sends outgoing messages via UDP
log 172.25.0.12:514 local0
@haproxytechblog
haproxytechblog / blog20190524-01.sh
Last active July 5, 2024 15:26
5 Ways to Extend HAProxy with Lua
$ haproxy -vv | grep Lua
Built with Lua version : Lua 5.3.5
@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 / blog20201221-01.cfg
Created December 21, 2020 14:53
Route SSH Connections with HAProxy
frontend fe_ssh
bind *:2222 ssl crt /etc/haproxy/certs/ssl.pem
mode tcp
log-format "%ci:%cp [%t] %ft %b/%s %Tw/%Tc/%Tt %B %ts %ac/%fc/%bc/%sc/%rc %sq/%bq dst:%[var(sess.dst)] "
tcp-request content set-var(sess.dst) ssl_fc_sni
use_backend %[ssl_fc_sni]
@haproxytechblog
haproxytechblog / blog20191008-01.sh
Last active March 27, 2024 20:59
HAProxy and Docker Swarm
$ apt update
$ apt install apt-transport-https ca-certificates curl gnupg2 software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ apt update
$ apt install docker-ce docker-ce-cli containerd.io
@haproxytechblog
haproxytechblog / blog20181127-01.cfg
Last active January 24, 2024 13:23
Bot Protection with HAProxy
backend per_ip_and_url_rates
stick-table type binary len 8 size 1m expire 24h store http_req_rate(24h)
backend per_ip_rates
stick-table type ip size 1m expire 24h store gpc0,gpc0_rate(30s)
$ curl --get --user admin:mypassword \
http://localhost:5555/v2/services/haproxy/configuration/backends
@haproxytechblog
haproxytechblog / haproxy-config-2-0.cfg
Created June 13, 2019 20:41
HAProxy 2.0 configuration
#
# This is the ultimate HAProxy 2.0 "Getting Started" config
# It demonstrates many of the features available which are now available
# While you may not need all of these things, this can serve
# as a reference for your own configurations.
#
# Have questions? Check out our community Slack:
# https://slack.haproxy.org/
#
@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 / blog20190207-01.sh
Last active August 9, 2023 22:05
Introduction to HAProxy Logging
sudo apt install -y rsyslog