Hi guys,
I was hoping for some help with explaining why setting up traefik has been so difficult self-hosting on docker. Don't get me wrong, learning configs for everything can be a challenge, but I've got everything else set up, from the *arr stack with docker compose and api keys, to non-docker apps using cron jobs and custom service scripts. A bit of copying and tweaking for your needs goes a long way.
But I can't get traefik working no matter what. I've copied a full config, and tweaked it, but the json wouldn't parse correctly, due to indentation. I've deleted the whole thing, and re-written from scratch, but nothing works. It seems traefik in particular randomizes parts of the indentation? My current file is below, and complains about the certresolvers not existing (specifically: error="field not found, node: certresolver") What I find really strange is the error it gave me with 2 spaces before address: :80 since that part requires 3 for reasons I have yet to figure out. More interestingly is that it seems my website does work anyway, sort of. All http requests are forwarded to https, and I do get a valid certificate, but visiting nginx.<mywebsite.com> returns a 404 error, which has made me check my dns records too many times to count.
I hope it's a dns issue I'm too dumb to have seen. I've got a record setup for wildcard subdomains and both ports 80 and 443 are forwards on the router and allowed through the firewall. I'm just stuck here.
docker-compose.yml with simple nginx server to test connection
services:
traefik:
container_name: traefik
image: traefik:latest
ports:
- 80:80
- 443:443
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./traefik/traefik.yml:/etc/traefik/traefik.yaml:ro
- ./traefik/conf/:/etc/traefik/conf/
- ./traefik/certs/:/etc/traefik/certs/
environment:
- CF_DNS_API_TOKEN=<token>
restart: unless-stopped
deploy:
resources:
limits:
memory: 250m
networks:
- frontend
nginx:
container_name: nginx
image: nginx:latest
ports:
- 84:80
restart: unless-stopped
deploy:
resources:
limits:
memory: 250m
networks:
- frontend
labels:
- traefik.enable=true
- traefik.http.routers.nginx-https.tls=true
- traefik.http.routers.nginx-https.certresolver=cloudflare
- traefik.http.routers.nginx-https.entrypoints=websecure
- traefik.http.routers.nginx-https.rule=Host('nginx.<mywebsite.com>')
networks:
frontend:
external: true
traefik.yml
global:
sendAnonymousUsage: false
Log:
Level: DEBUG
entryPoints:
web:
address: :80
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: :443
certificatesResolvers:
cloudflare:
acme:
email: <myemail>@gmail.com
storage: /etc/traefik/certs/cloudflare-acme.json
caServer: "https://acme-v02.api.letsencrypt.org/directory"
dnsChallenge:
provider: cloudflare
resolvers:
- "1.1.1.1:53"
- "8.8.8.8:53"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
network: frontend