I need tighter and cleaner control over some config options and so I decided to change my config from a docker-compose.yaml file to separate static/dynamic files. However, now I get a connection refused error when trying to hit any routes, and I can't seem to figure out why - the Traefik logs don't seem to indicate that anything is misconfigured.
This is my new config setup:
/etc/traefik/traefik.yaml (new)
api:
dashboard: true
debug: true
entryPoints:
web:
address: ":80"
websecure:
address: ":443"
providers:
file:
filename: "/etc/traefik/dynamic_config.yaml"
watch: true
docker: {}
certificatesResolvers:
myresolver:
acme:
email: "me@example.com"
storage: "/etc/traefik/letsencrypt/acme.json"
tlsChallenge: {}
/etc/traefik/dynamic_config.yaml (new)
http:
routers:
flame:
rule: "Host(`example.com`)" # real domain is used
service: "flame"
tls:
certResolver: "myresolver"
gotify:
rule: "Host(`gotify.example.com`)"
service: "gotify"
tls:
certResolver: "myresolver"
/opt/appdata/docker-compose.yaml (new)
version: "3.8"
services:
traefik:
image: traefik:v2.9
command: --api.insecure=true --providers.docker
ports:
- 80:80
- 443:443
- 9090:8080 # The Web UI (enabled by --api.insecure=true)
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /etc/traefik/letsencrypt:/letsencrypt
flame:
image: pawelmalak/flame
container_name: flame
volumes: ...
environment: ...
ports: ...
restart: unless-stopped
gotify:
image: gotify/server
container_name: gotify
environment: ...
ports: ...
volumes: ...
restart: unless-stopped
... and this is my previous config setup, which was working
/opt/appdata/docker-compose.yaml (old)
version: "3.8"
services:
traefik:
image: traefik:v2.9
command:
- "--log.level=DEBUG"
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--entrypoints.web.http.redirections.entrypoint.scheme=https"
- "--certificatesresolvers.myresolver.acme.tlschallenge=true"
- "--certificatesresolvers.myresolver.acme.email=me@example.com"
- "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
ports:
- 80:80
- 443:443
- 9090:8080 # The Web UI (enabled by --api.insecure=true)
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- /opt/appdata/letsencrypt:/letsencrypt # I moved this to /etc/traefik in the new setup
flame:
image: pawelmalak/flame
container_name: flame
volumes: ...
environment: ...
ports: ...
labels:
- "traefik.enable=true"
- "traefik.http.routers.flame.rule=Host(`example.com`)"
- "traefik.http.routers.flame.entrypoints=web,websecure"
- "traefik.http.routers.flame.tls.certresolver=myresolver"
restart: unless-stopped
gotify:
image: gotify/server
container_name: gotify
environment: ...
ports: ...
volumes: ...
labels:
- "traefik.enable=true"
- "traefik.http.routers.gotify.rule=Host(`gotify.example.com`)"
- "traefik.http.routers.gotify.entrypoints=web,websecure"
- "traefik.http.routers.gotify.tls.certresolver=myresolver"
restart: unless-stopped
I've combed through the documentation and I'm not sure what the problem could be. I can access the Traefik web UI just fine, and the services and routers are listed, but trying to hit my domain using a web browser immediately gets me an "Unable to Connect" message, and curl gives me this:
$ curl https://example.com # real domain is used
curl: (7) Failed to connect to example port 443 after 48 ms: Connection refused
Edit: additional troubleshooting I've done:
- If I try and access my domain using http (no ssl) I get a 404.
- I've ensured my acme.json file has the correct permissions.
- I'm able to access my services using the local IP/port given in the HTTP Services section of the Traefik web ui.
- The same problem exists using the LetsEncrypt caServer.
I'd sure appreciate any help. Thanks in advanced.