Last active
June 8, 2022 15:48
-
-
Save ndom91/21770616bd6ec50f148a990b1b9468a1 to your computer and use it in GitHub Desktop.
HAProxy JSON Body Routing Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global | |
stats socket /var/run/api.sock user haproxy group haproxy mode 660 level admin expose-fd listeners | |
log stdout format raw local0 info | |
defaults | |
mode http | |
timeout client 10s | |
timeout connect 5s | |
timeout server 10s | |
timeout http-request 10s | |
log global | |
frontend proxylambda | |
bind localhost:4575 | |
acl runtime202206 req.body -m reg \"runtime\":.*\"2022.06\" | |
use_backend node16 if runtime202206 | |
acl runtime202202 req.body -m reg \"runtime\":.*\"2022.02\" | |
use_backend node14 if runtime202202 | |
acl runtime202110 req.body -m reg \"runtime\":.*\"2021.10\" | |
use_backend node14 if runtime202110 | |
acl runtime202106 req.body -m reg \"runtime\":.*\"2021.06\" | |
use_backend node14 if runtime202106 | |
default_backend node12 | |
option forwardfor | |
backend node12 | |
balance roundrobin | |
server node12 localhost:4580 check | |
backend node14 | |
balance roundrobin | |
server node14 localhost:4581 check | |
backend node16 | |
balance roundrobin | |
server node16 localhost:4582 check |
Or with docker-compose
, something like this:
version: '2'
services:
haproxy:
image: haproxy:alpine
container_name: haproxy
restart: always
depends_on:
- node12
- node14
- node16
ports:
- "4575:4575"
volumes:
- haproxy.cfg:/usr/local/etc/haproxy
networks:
- checkly_lambda
# ... node containers, etc.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Then in whichever directory you're in there,
sudo docker run -d \ --name haproxy \ --net mynetwork \ -v $(pwd):/usr/local/etc/haproxy:ro \ -p 4575:4575 \ haproxytech/haproxy-alpine:latest