I have a compose.yaml serving WordPress with a Traefik reverse proxy. The https port 443 loopback for the WordPress container fails by default because the WordPress container only listens on http port 80. I need to have the loopback go through the reverse proxy. I can do this by adding the site's domain to the extra_hosts, but I have to hardcode the traefik container IP address, which happens to be 172.18.0.2. What's the proper way to add a record to the WordPress container's /etc/hosts file with the Traefik container's IP address?
services:
traefik:
image: traefik
ports:
- 80:80
- 443:443
...
wordpress:
image: wordpress
extra_hosts:
# how to avoid hardcoding traefik container IP here?
- mysite.com:172.18.0.2
...