Skip to content

Instantly share code, notes, and snippets.

@haproxytechblog
haproxytechblog / blog20220304-01.sh
Created March 4, 2022 23:10
Use Your Load Balancer to Monitor Application Health
$ haproxy -vv | grep "Prometheus exporter"
Built with the Prometheus exporter as a service
@haproxytechblog
haproxytechblog / blog20220221-01.sh
Created February 21, 2022 14:46
Announcing HAProxy Data Plane API 2.5
$ curl -X PUT \
-–user admin:password \
-H "Content-Type: application/json" \
-d '{
"name": "test",
"mode": "http",
"http-check": {
"type": "expect",
"match": "status",
"pattern": "200,201,300-310"
@haproxytechblog
haproxytechblog / blog20220203-01.sh
Created February 3, 2022 21:37
Load Balance an Infinite Number of Servers And Never Reload HAProxy
$ echo "experimental-mode on; add server be_app/server10 10.0.1.5:80 check" |\
socat stdio tcp4-connect:127.0.0.1:9999
@haproxytechblog
haproxytechblog / blog20211213-01.cfg
Last active December 20, 2021 16:02
Log4Shell Protection
frontend myfrontend
option http-buffer-request
acl log4shell url,url_dec -i -m reg (?:\${[^}]{0,4}\${|\${(?:jndi|ctx))
acl log4shell req.hdrs -i -m reg (?:\${[^}]{0,4}\${|\${(?:jndi|ctx))
acl log4shell_form req.body,url_dec -i -m reg (?:\${[^}]{0,4}\${|\${(?:jndi|ctx))
http-request deny if log4shell
http-request deny if { req.fhdr(content-type) -m str application/x-www-form-urlencoded } log4shell_form
@haproxytechblog
haproxytechblog / blog20211111-01a.sh
Last active January 8, 2022 17:20
Announcing HAProxy 2.5
$ socat stdio tcp4-connect:127.0.0.1:9999
prompt
>
@haproxytechblog
haproxytechblog / blog20211008-01.sh
Created October 8, 2021 15:21
Announcing HAProxy Data Plane API 2.4
$ sudo dataplaneapi \
--host 127.0.0.1 \
--port 5555 \
--haproxy-bin /usr/sbin/haproxy \
--config-file /etc/haproxy/haproxy.cfg \
--reload-delay 5 \
--reload-cmd "service haproxy reload" \
--restart-cmd "service haproxy restart" \
--userlist haproxy-dataplaneapi \
--transaction-dir /tmp/haproxy
@haproxytechblog
haproxytechblog / blog20211007-01.yml
Last active August 3, 2023 23:08
Announcing HAProxy Kubernetes Ingress Controller 1.7
apiVersion: v1
kind: Service
metadata:
labels:
run: web
name: web
annotations:
haproxy.org/check: "true"
haproxy.org/check-http: "/health"
@haproxytechblog
haproxytechblog / blog20210903-01.yaml
Last active September 8, 2021 16:07
Rate Limiting with the HAProxy Kubernetes Ingress Controller
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: web-ingress
namespace: default
annotations:
  haproxy.org/rate-limit-requests: 10
@haproxytechblog
haproxytechblog / blog20210902-01.cfg
Created September 2, 2021 18:24
September/2021 - Duplicate 'Content-Length' Header Fixed
frontend myfrontend
http-request deny if { req.hdr_cnt(content-length) gt 1 }
http-response deny if { res.hdr_cnt(content-length) gt 1 }
@haproxytechblog
haproxytechblog / blog20210820-01.cfg
Created August 20, 2021 14:30
How to Enable Health Checks in HAProxy
backend webservers
server server1 192.168.50.2:80 check
server server2 192.168.50.3:80 check
server server3 192.168.50.4:80 check