Traefik api basePath seems not works

I recently tried traefik now
very first, I just use anything else but example
it worked very well.

so I tried one line per try to check any other problem.
it's quite good, but after try basePath, it suddenly get 404

more worse thing is, it's not work even I commented basePath in config, and remove pathprefix from label. (this was just worked before I tried basepath)

# docker-compose
services:
  traefik:
    image: traefik:latest
    container_name: traefik
    secrets:
      - cloudflare_api
    environment:
      - CF_DNS_API_TOKEN=/run/secrets/cloudflare_api
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /opt/docker/config/traefik/traefik.yml:/etc/traefik/traefik.yml:ro
      - /opt/docker/config/traefik/data/certs:/var/traefik/certs:rw
    networks:
      - proxy
    labels:
      - traefik.enable=true
      - traefik.http.routers.dashboard.rule=Host(`server.domain.test`) && PathPrefix(`/traefik`)

      - traefik.http.routers.dashboard.service=api@internal
      - traefik.http.routers.dashboard.middlewares=auth
      - traefik.http.middlewares.auth.basicauth.users=test:$$apr1$$H6uskkkW$$IgXLP6ewTrSuBkTrqE8wj/
    restart: unless-stopped
networks:
  proxy:
    external: true
# config/traefik/traefik.yml
global:
  checkNewVersion: false
  sendAnonymousUsage: false

log:
  level: DEBUG

api:
  dashboard: true
  insecure: false
  basePath: /traefik

entryPoints:
  web:
    address: :80
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https
  websecure:
    address: :443

certificatesResolvers:
  cloudflare:
    acme:
...

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

Found solution

if you want to use 'secrets' for token

then you need to use environment name as CF_DNS_TOKEN_API_FILE. document does not mention this, but I found it from youtube.

1 Like

It is mention in the Traefik LetsEncrypt doc:

Many lego environment variables can be overridden by their respective _FILE counterpart, which should have a filepath to a file that contains the secret as its value. For example, CF_API_EMAIL_FILE=/run/secrets/traefik_cf-api-email could be used to provide a Cloudflare API email address as a Docker secret named traefik_cf-api-email.
For complete details, refer to your provider's Additional configuration link

god.. my eyes... thanks

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.