Good morning.
I'm trying to set up traefik with docker swarm, I have been following this guide https://dockerswarm.rocks/ but I'm stuck.
This is my current setup:
traefik.yml
api:
dashboard: true
entryPoints:
web:
address: ":80"
http:
redirections:
entryPoint:
to: websecure
scheme: https
websecure:
address: ":443"
providers:
docker:
endpoint: "unix:///var/run/docker.sock"
exposedByDefault: false
swarmMode: true
file:
filename: /traefik-dynamic.yml
watch: true
certificatesResolvers:
lets-encrypt:
acme:
email: some_email
storage: acme.json
httpChallenge:
entryPoint: web
log:
filePath: "/log.log"
level: DEBUG
treaefik-dynamic.yml
http:
middlewares:
traefik-auth:
basicAuth:
users:
- "user:hash"
docker-compose.yml
for traefik
version: '3'
services:
traefik:
image: traefik:latest
container_name: traefik
restart: unless-stopped
security_opt:
- no-new-privileges:true
deploy:
placement:
constraints:
# Make the traefik service run only on the node with this label
# as the node with it has the volume for the certificates
#- node.labels.traefik-public.traefik-public-certificates == true
- node.role == manager
labels:
- "traefik.enable=true"
- "traefik.http.routers.traefik.rule=Host(`traefik2.domain.net`)"
- "traefik.http.routers.traefik.entrypoints=websecure"
#- "traefik.http.routers.traefik.middlewares=traefik-auth@file"
- "traefik.http.services.traefik.loadbalancer.server.port:8080"
- "traefik.http.routers.traefik.tls=true"
- "traefik.http.routers.traefik.tls.certresolver=lets-encrypt"
- "traefik.http.routers.traefik.service=api@internal"
command:
- --entrypoints.redis.address=:6379 # Redis endpoint.
ports:
- 80:80
- 443:443
- 8080:8080
volumes:
- /etc/localtime:/etc/localtime:ro
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/traefik.yml:/traefik.yml:ro
- ./data/traefik-dynamic.yml:/traefik-dynamic.yml:ro
- ./data/acme.json:/acme.json
- ./data/log.log:/log.log
- ./certs:/certs
networks:
- traefik-public
networks:
traefik-public:
external: true
When I go to the dashboard I get 404 error. But the certificate is valid. Here's what I'm continuously seeing on the log:
time="2023-05-05T07:25:11Z" level=debug msg="Serving default certificate for request: """
time="2023-05-05T07:25:12Z" level=error msg="field not found, node: port:8080" providerName=docker container=traefik-traefik-96up1dje2kilr0vn5f9mfxw1a
time="2023-05-05T07:25:12Z" level=debug msg="Configuration received: {"http":{},"tcp":{},"udp":{}}" providerName=docker
time="2023-05-05T07:25:12Z" level=debug msg="Skipping unchanged configuration." providerName=docker
time="2023-05-05T07:25:27Z" level=error msg="field not found, node: port:8080" providerName=docker container=traefik-traefik-96up1dje2kilr0vn5f9mfxw1a
time="2023-05-05T07:25:27Z" level=debug msg="Configuration received: {"http":{},"tcp":{},"udp":{}}" providerName=docker
time="2023-05-05T07:25:27Z" level=debug msg="Skipping unchanged configuration." providerName=docker
But I don't see what's wrong with the port definition. Precisesly as I understand it specifing the port is a must in docker swarm.