HAProxy with a custom Lua script to lookup the domain in an API to decide which backend to use.
393
This container runs an HAProxy instance with a custom Lua script that looks up the request domain against an API to decide which backend to use. The result can optionally be cached locally to improve subsequent requests.
(1.) Create your own haproxy.cfg file. Use the default one as an example.
(2.) Create your own backend-lookup-config.lua file to define the lookup service.
See below for info about the lookup service.
(3.) Build the container:
docker build -t haproxy-lookup-backend .
(4.) Run the container:
# http://localhost:4000/ -> haproxy port 80
docker run -p 4000:80 haproxy-lookup-backend
You can mount the config files so you don't need to rebuild every time you run. Useful for testing.
docker run -p 4000:80 \
-v `pwd`/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg \
-v `pwd`/backend-lookup.lua:/usr/local/etc/haproxy/backend-lookup.lua \
haproxy-lookup-backend
domaink=v pairs, one per linebackend_name key, which is the name of the backend to useExample request:
Host: my-api.example.com
GET /lookup.txt?domain=foobar.com
Example response:
backend_name = php7_backend
x-custom-header = value
x-something-else = value
Content type
Image
Digest
Size
71.3 MB
Last updated
about 9 years ago
docker pull chroder/haproxy-lookup-backend