A Caddy module that routes requests by looking up upstream addresses via HTTP.
Build Caddy with this module:
xcaddy build --with github.com/AnswerDotAI/caddy-http-routerThe module extracts the subdomain from incoming requests and calls your lookup service.
Your service should return plain text host:port or 404 if not found.
{
"handler": "http_router",
"lookup_url": "http://localhost:5002/lookup"
}Then use with reverse_proxy:
{
"handler": "reverse_proxy",
"upstreams": [{"dial": "{http.vars.backend_upstream}"}]
}http_router {
lookup_url http://localhost:5002/lookup
timeout 1000
}
reverse_proxy {http.vars.backend_upstream}| Option | Default | Description |
|---|---|---|
lookup_url |
(required) | URL of the lookup service (subdomain appended) |
timeout |
1000 | HTTP timeout in milliseconds |