Skip to content

Instantly share code, notes, and snippets.

@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 / blog20181210-01.sh
Last active December 10, 2018 18:41
Building a Service Mesh with HAProxy and Consul
cd blog/building_service_mesh
docker-compose up -d consul-server
# Wait for consul-server to bootstrap itself
sleep 10
# Create ACL token that agents use to connect to consul-server
docker-compose exec consul-server curl --request PUT --header "X-Consul-Token: mastertoken" --data '{ "ID": "agenttoken", "Name": "Agent Token", "Type": "client", "Rules": "node \"\" { policy = \"write\" } service \"\" { policy = \"write\" }" }' http://localhost:8500/v1/acl/create
sleep 1
@haproxytechblog
haproxytechblog / blog20181219-01.cfg
Last active December 20, 2018 18:39
HAProxy 1.9 Has Landed
option http-use-htx
@haproxytechblog
haproxytechblog / blog20190214
Created February 14, 2019 14:31
Power of Two Load Balancing
GET /MyTime/bob HTTP/1.1
Host: mytime.example.local
HTTP/1.0 200 OK
Server: BaseHTTP/0.6 Python/3.6.7
Date: Tue, 22 Jan 2019 16:38:11 GMT
<HTML><BODY>Hello Bob Smith, your IP address is 198.18.0.7 and your local time is 10:38.</BODY></HTML>
@haproxytechblog
haproxytechblog / blog20190228-01.cfg
Last active March 1, 2019 18:26
API Gateway Part 3
backend apiservers
balance roundrobin
server server1 192.168.50.3:80 check
@haproxytechblog
haproxytechblog / blog20190314-01.sh
Last active March 14, 2019 16:10
IP Masking in HAProxy
Feb 8 20:51:28 server1 haproxy[4718]: 192.168.50.5 [08/Feb/2019:20:51:28.816] website~ servers/server1 0/0/0/1/1 304 180 - - ---- 1/1/0/1/0 0/0 "GET / HTTP/1.1"
@haproxytechblog
haproxytechblog / blog20190402-01.cfg
Last active April 3, 2019 13:52
Extending HAProxy with the Stream Processing Offload Engine
frontend myproxy
filter spoe [engine <name>] config <spoe-config-file>
@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 / blog20190426-01.sh
Created April 26, 2019 13:31
HAProxy on AWS: Best Practices Part 3
$ apt update
$ apt install -y unzip
$ wget -O ./terraform.zip https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
$ unzip ./terraform.zip -d ./terraform
$ cp ./terraform/terraform /usr/local/bin
@haproxytechblog
haproxytechblog / blog20190116-01.cfg
Created January 16, 2019 18:40
HAProxy 1.9.2 Adds gRPC Support
frontend fe_mysite
bind :443 ssl crt /path/to/cert.pem alpn h2,http/1.1
default_backend be_servers