Hello, In the following docker-compose.yml file I have two simple services named main and blog. The test site is live and has the letsencrypt certs. When I navigate to the site the main service runs as expected. However, when I go to the site with "/blog" the main service is still run and the blog service is not run.
Does anyone know what I am doing wrong? Thanks!
version: "3"
services:
reverse-proxy:
# # The official v2.0 Traefik docker image
image: traefik:v2.0
ports:
# # The HTTP port
- "80:80"
# # The HTTPS port
- "443:443"
restart: unless-stopped
command:
- --providers.docker=true
- --providers.docker.exposedbydefault=false # <== MUST enable this container for redirect and certs
# - --providers.docker.network=tiangolo_default
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --certificatesResolvers.mydnschallenge.acme.email=emailgoeshere
- --certificatesResolvers.mydnschallenge.acme.dnsChallenge=true
- --certificatesResolvers.mydnschallenge.acme.dnsChallenge.provider=linodev4
- --certificatesResolvers.mydnschallenge.acme.storage=/acme.json # <== must be 600 permissions per docs
- --certificatesResolvers.mydnschallenge.acme.dnsChallenge.delayBeforeCheck=0
# - --certificatesResolvers.mydnschallenge.acme.caServer=https://acme-staging-v02.api.letsencrypt.org/directory # <== for dev only
volumes:
- /var/run/docker.sock:/var/run/docker.sock # <== So that Traefik can listen to the Docker events
- ./acme.json:/acme.json # <== keep letsencrypt certs up to date
environment:
- LINODE_TOKEN=tokengoeshere
labels:
- "traefik.enable=true" # <== This MUST be set!!!
# # global redirect to https
- "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
- "traefik.http.routers.http-catchall.entrypoints=web"
- "traefik.http.routers.http-catchall.middlewares=https_redirect"
- "traefik.http.middlewares.https_redirect.redirectscheme.scheme=https" # <== middleware redirect
- "traefik.http.middlewares.https_redirect.redirectscheme.permanent=true"
# # init_certs
- "traefik.http.routers.init_certs.rule=Host(`${HOST_NAME}`)"
- "traefik.http.routers.init_certs.tls.certresolver=mydnschallenge" # <== this creates privatekey and cert=null in acme.json, can take about 20mins for cert
- "traefik.http.routers.init_certs.tls.domains[0].main=${HOST_NAME}"
- "traefik.http.routers.init_certs.tls.domains[0].sans=*.${HOST_NAME}"
#
#
main:
build: ./main
container_name: main
volumes:
- ./main/app:/app
labels:
- "traefik.enable=true"
- "traefik.http.routers.main_route.rule=Host(`${HOST_NAME}`, `www.${HOST_NAME}`)"
- "traefik.http.routers.main_route.tls=true"
#
#
blog:
build: ./blog
container_name: blog
volumes:
- ./blog/app:/app
labels:
- "traefik.enable=true"
- "traefik.http.routers.blog_route.rule=Host(`${HOST_NAME}`) && PathPrefix(`/blog`)"
- "traefik.http.routers.blog_route.tls=true"
# - "traefik.http.routers.blog_route.middlewares=test_stripprefix"
# - "traefik.http.middlewares.test_stripprefix.stripprefix.prefixes=/blog"