Page tree
Skip to end of metadata
Go to start of metadata

#!/bin/bash
source .env
TID=`curl -X POST --user dataplaneapi:mypassword -H "Content-Type: application/json" http://localhost/v1/services/haproxy/transactions?version=1 | /usr/bin/jq -r ".id"`
curl -X POST --user dataplaneapi:mypassword -H "Content-Type: application/json" \
-d '{"name": "'"$SERVER"'", "mode":"http"}' "http://localhost/v1/services/haproxy/configuration/backends?transaction_id=$TID"
curl -X POST --user dataplaneapi:mypassword -H "Content-Type: application/json" \
-d '{"name": "'"$SERVER"'", "address": "'"$DOCKERHOST"'", "port": 80, "check": "enabled", "maxconn": 30, "weight": 100}' "http://localhost/v1/services/haproxy/configuration/servers?backend="$SERVER"&transaction_id=$TID"
curl -X POST --user dataplaneapi:mypassword -H "Content-Type: application/json" \
-d '{"id": 0, "acl_name": "'"$COND"'", "criterion": "req.hdr(Host)", "value": "'"$SERVER"'.com"}' "http://localhost/v1/services/haproxy/configuration/acls?parent_type=frontend&parent_name=http&transaction_id=$TID"
curl -X POST --user dataplaneapi:mypassword -H "Content-Type: application/json" \
-d '{"id": 0, "cond": "if", "cond_test": "'"$COND"'", "name": "'"$SERVER"'"}' "http://localhost/v1/services/haproxy/configuration/backend_switching_rules?frontend=http&transaction_id=$TID"
curl -X PUT --user dataplaneapi:mypassword -H "Content-Type: application/json" http://localhost/v1/services/haproxy/transactions/$TID



pass var with

docker-compose exec haproxy bash -c "printf VAR=THIS\nVAR2=THAT >> .env && ./start.sh"

  • No labels
Write a comment…