This is my first time trying to set up Traefik in a docker container on my Synology NAS. Everything seems to be functioning correctly on my local network and I can access it from my WAN IP as well, but I can't get it to work from my domain. I am just getting 404's. I have tried countless combinations of labels and commands, but I haven't been able to progress any further. I wondered if someone could please offer some advice on how to proceed.
Thanks in advance.
version: "3.9"
services:
traefik:
image: traefik:latest
container_name: traefik
restart: always
environment:
- "CF_API_EMAIL=${CF_API_EMAIL}"
- "CF_API_KEY=${CF_API_KEY}"
- "TZ=${TZ}"
volumes:
- "/volume1/docker/traefik/data:/data"
- "/var/run/docker.sock:/var/run/docker.sock"
command:
- --api.insecure=true # <== Enabling insecure api, NOT RECOMMENDED FOR PRODUCTION
- --api.dashboard=true # <== Enabling the dashboard to view services, middlewares, routers, etc.
- --api.debug=true # <== Enabling additional endpoints for debugging and profiling
- --log.level=DEBUG # <== Setting the level of the logs from traefik
- --providers.docker=true # <== Enabling docker as the provider for traefik
- --providers.docker.exposedbydefault=false # <== Don't expose every container to traefik
# - --providers.file.filename=/dynamic.yaml # <== Referring to a dynamic configuration file
- --providers.docker.network=web # <== Operate on the docker network named web
- --entrypoints.web.address=:80 # <== Defining an entrypoint for port :80 named web
- --entrypoints.web-secured.address=:443 # <== Defining an entrypoint for https on port :443 (not really needed)
networks:
- macvlan_network
- web
labels:
- "traefik.enable=true" # <== Enable traefik on itself to view dashboard and assign subdomain to$
- "traefik.http.routers.api.rule=Host(`monitor.mitchcomp.au`)" # <== Setting the domain for the d$
- "traefik.http.routers.api.service=api@internal" # <== Enablin
networks:
macvlan_network:
name: macvlan_network
driver: macvlan
driver_opts:
parent: eth0
ipam:
config:
- subnet: "192.168.0.0/24"
ip_range: "192.168.0.240/32"
gateway: "192.168.0.1"
web:
external: true
Thanks @bluepuma77. I tried this, but because my NAS makes use of 80 and 443 ports I couldn't use the simple example. I made changes to run over a macvlan, however I now get a ERR_TOO_MANY_REDIRECTS error even using the local ip. But I had to comment out the proxy and whoami portions otherwise it threw:
Error response from daemon: driver failed programming external connectivity on endpoint traefik-traefik-1 (9abdeb1b021ebd85e63861f20c30d756afa40d765a00651c0c822831e933d6a1): Error starting userland proxy: listen tcp4 0.0.0.0:443: bind: address already in use
I tried using alternative ports initially, but I still couldn't get it to work. Plus, I read that macvlan was the best way to deal with port conflict. I will try the method you suggested, using the modified ports.
@bluepuma77 - I noticed this post you replied to earlier and tried using the docker-compose you included in your reply. This also results in a 522 error from Cloud flare.
Try without Cloudflare tunnel/proxy first, it has a lot of configuration that can go wrong. When basic Traefik works, then you can go the next step and add another component in front.