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
...
mysite.com
is going to resolve to the swarms external ip anyway, which is where traefik is listening anyway.mysite.com
as anextra_hosts
, then the loopback check fails with a connection timeout. Either using the Traefik container's IP as anextra_hosts
or the alias solution resolves the issue with the loopback check finally succeeding.