I am trying to fix "Failed to connect to myexample.com port 443: Connection refused". I think this is what's going on. Help would be amazing!
I have a Wordpress Docker container that is sending requests to itself. So curl -v https://myexample.com
will return the above error. These are failing I think because the container doesn't support https. HTTPS is the job of the reverse proxy (traefik) that's in another container.
With my docker-compose file in mind, what's the solution for this?
One option I can imagine is for the WP container to have myexample.com resolve to the proxy instead of itself. The proxy can then manage the https request and send the response back to the WP container.
Is that the correct / best way of doing it?
If so, on the WP container, how do I resolve myexample.com to the proxy? (obviously with the hosts file but how/what values). This is my summarised docker-compose file.
services:
traefik:
image: traefik:2.3
container_name: traefik
network_mode: web
ports:
- '80:80'
- '443:443'
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- $PWD/traefik:/etc/traefik
db:
...
www:
image: wordpress:latest
container_name: www
networks:
- web
- internal
depends_on:
- db
links:
- db:mysql
volumes:
- wp-data:/var/www/html
labels:
- traefik.http.routers.retro.rule=Host(`myexample.com`)
- traefik.http.routers.retro.middlewares=myHeaders@file
- traefik.http.routers.retro.tls=true
- traefik.http.routers.retro.tls.certResolver=lets-encrypt
- traefik.port=80
volumes:
wp-data:
networks:
web:
external: true
internal:
external: false
Thank you!
question from:
https://stackoverflow.com/questions/65876746/how-do-i-get-a-docker-container-thats-requesting-urls-from-itself-to-go-via-rev 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…