I am migrating Traefik V1 to V2 with some strange issues. when i use the app name with the subdomainname, Traefik works perfectly fine. However, some containers wont works when using a different name.
For example ( app name nextcloud > cloud.example.com)
There is only one container which is working with a different name. But looks the name as the other ones.
Here is my compose file:
networks:
reverseproxy:
name: reverseproxy
dockersock-proxy:
name: dockersock-proxy
external: true
intern:
name: intern
nextcloud:
name: nextcloud
services:
traefik2:
container_name: traefik2
image: traefik:cantal
restart: always
command:
- --global.checkNewVersion=true
- --global.sendAnonymousUsage=false
- --entryPoints.http.address=:80
# https://www.reddit.com/r/docker/comments/c1wrep/traefik_reverse_proxy_question_docker_overlay/
# - --entrypoints.http.forwardedHeaders.trustedIPs=127.0.0.1/31, 192.168.90.1/24
# - --entrypoints.http.proxyProtocol=true
# - --entrypoints.http.proxyProtocol.trustedIPs=127.0.0.1/31, 192.168.90.1/24
- --entryPoints.https.address=:443
- --entryPoints.traefik.address=:8080
# - --api=true
- --api.insecure=true
# - --serversTransport.insecureSkipVerify=false
- --log=true
- --log.level=INFO # (Default: error) DEBUG, INFO, WARN, ERROR, FATAL, PANIC
- --accessLog=true
- --accessLog.filePath=/var/log/docker/traefik.log
- --accessLog.bufferingSize=100 # Configuring a buffer of 100 lines
- --accessLog.filters.statusCodes=400-499
- --providers.docker=true
# - --providers.docker.defaultrule=Host(`{{ index .Labels "com.docker.compose.service" }}.$DOMAINBASE`)
- --providers.docker.exposedByDefault=false
- --providers.docker.network=reverseproxy
# - --providers.docker.endpoint=tcp://dockersock-proxy:2375
- --providers.docker.swarmMode=false
- --providers.file.directory=/rules
- --providers.file.watch=true
- --certificatesresolvers.ovh.acme.dnschallenge=true
# - --certificatesResolvers.ovh.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory # uncomment when testing
- --certificatesResolvers.ovh.acme.email=${SMTP_DEST_EMAIL}
- --certificatesResolvers.ovh.acme.storage=/acme.json
- --certificatesResolvers.ovh.acme.dnsChallenge.provider=ovh
networks:
- reverseproxy
- dockersock-proxy
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- $USERDIR/traefik2/rules:/rules
- $USERDIR/traefik2/acme.json:/acme.json
- $USERDIR/traefik2/traefik.log:/var/log/docker/traefik.log
- /var/run/docker.sock:/var/run/docker.sock
environment:
OVH_ENDPOINT: ovh-eu
OVH_APPLICATION_KEY: ${OVH_APPLICATION_KEY}
OVH_APPLICATION_SECRET: ${OVH_APPLICATION_SECRET}
OVH_CONSUMER_KEY: ${OVH_CONSUMER_KEY}
labels:
- "traefik.enable=true"
# HTTP-to-HTTPS Redirect
- "traefik.http.routers.http-catchall.entrypoints=https"
- "traefik.http.routers.http-catchall.rule=HostRegexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
- "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
# HTTP Routers
- "traefik.http.routers.traefik-rtr.entrypoints=https"
- "traefik.http.routers.traefik-rtr.rule=Host(`traefik.$DOMAINBASE`)"
- "traefik.http.routers.traefik-rtr.tls=true"
- "traefik.http.routers.traefik-rtr.tls.certresolver=ovh"
- "traefik.http.routers.traefik-rtr.tls.domains[0].main=$DOMAINBASE"
- "traefik.http.routers.traefik-rtr.tls.domains[0].sans=*.$DOMAINBASE"
## Middlewares
## Services - API
- "traefik.http.routers.traefik-rtr.service=api@internal"
portainer:
container_name: portainer
hostname: portainer
restart: unless-stopped
image: portainer/portainer
user: ${PUID}
command: -H tcp://dockersock-proxy:2375 --no-auth
volumes:
- ${USERDIR}/portainer:/data
ports:
- "9000:9000"
environment:
TZ: ${TZ}
depends_on:
- dockersock-proxy
networks:
- reverseproxy
- dockersock-proxy
labels:
- "traefik.enable=true"
## HTTP Routers
- "traefik.http.routers.portainer-rtr.entrypoints=https"
- "traefik.http.routers.portainer-rtr.rule=Host(`piet.$DOMAINBASE`)"
- "traefik.http.routers.portainer-rtr.tls=true"
- "traefik.http.routers.portainer-rtr.tls.certresolver=ovh"
## Middlewares
## HTTP Services
- "traefik.http.routers.portainer-rtr.service=portainer-svc"
- "traefik.http.services.portainer-svc.loadbalancer.server.port=9000"
nextcloud:
container_name: nextcloud
restart: unless-stopped
image: nextcloud:18.0
hostname: nextcloud
volumes:
- ${USERDIR}/nextcloud:/var/www/html
- /srv/dev-disk-by-label-Data/nextcloud:/var/www/html/data
depends_on:
- nextcloud-mariadb
- nextcloud-redis
- nextcloud-news
ports:
- "90:80"
user: ${PUID}
environment:
TZ: ${TZ}
NEXTCLOUD_TRUSTED_DOMAINS: thuis.${DOMAINBASE}
REDIS_HOST: nextcloud-redis
sysctls:
net.ipv4.ip_unprivileged_port_start: "0"
networks:
- reverseproxy
- nextcloud
labels:
- "traefik.enable=true"
- "traefik.http.routers.nextcloud-rtr.entrypoints=https"
- "traefik.http.routers.nextcloud-rtr.rule=Host(`nextcloud.$DOMAINBASE`)"
- "traefik.http.routers.nextcloud-rtr.tls=true"
- "traefik.http.routers.nextcloud-rtr.tls.certresolver=ovh"
## Middlewares
## HTTP Services
- "traefik.http.routers.nextcloud-rtr.service=nextcloud-svc"
- "traefik.http.services.nextcloud-svc.loadbalancer.server.port=80"
Portainer works with all the subdomainnames (for example piet), but nextcloud wont works a domain other thhen nextcloud.example.com. For this example there is no middleware.
I cant finnd the correct answer after 3 days..... Any idea?