I have a docker image containing an OpenResty server. I am running it within a docker-compose file like this:
version: '2.1'
services:
dev.example.com:
# etc.
If I set the resolver
to use the Docker one in the OpenResty configuration, then I can refer to dev.example.com
and it resolves to the correct IP:
http {
resolver 127.0.0.11;
}
However, I would prefer not to name the service dev.example.com
, and instead use hostname
and domainname
in docker-compose:
version: '2.1'
services:
proxy:
domainname: example.com
hostname: dev
# etc.
This would enable me to use environment variables to control the hostname. The problem is that when I use these parameters instead of the service name, dev.example.com
can no longer be resolved within the Lua blocks, even though basic tests with ping
, curl
etc. from within the running container resolve correctly, and a simple block like this works in either case:
location /test {
proxy_pass https://dev.example.com/static.html
}
How can I configure the domain/hostname dynamically without changing the service name, in a way that is compatible with OpenResty?