Hey everyone,
I am running two separate docker containers, one for a static web page and one for shlink (link shortener). Both are on the proxy network which I use to make my frontend services accessible to traefik (I don't expose any ports on these containers).
NOTE: Currently my NAME.link domain is using proxied DNS by Cloudflare, though this shouldn't be a problem as the access log looks fine with the Paths.
My challenge is the following: route all web traffic to the static web page, but use the same domain name with a path prefix /shlink
for my link shortener.
Labels for static web page:
- "traefik.enable=true"
- "traefik.http.routers.welcome-page.rule=Host(`NAME.link`)
- "traefik.http.routers.welcome-page.priority=1"
- "traefik.http.routers.welcome-page.entrypoints=websecure"
- "traefik.http.routers.welcome-page.middlewares=security-chain@file"
Labels for shlink:
- "traefik.enable=true"
- "traefik.http.routers.shlink.rule=Host(`NAME.link`) && PathPrefix(`/shlink`)"
- "traefik.http.routers.shlink.priority=20"
- "traefik.http.routers.shlink.entrypoints=websecure"
- "traefik.http.services.shlink.loadbalancer.server.port=8080"
- "traefik.http.routers.shlink.middlewares=security-chain@file,cors" # Delete CORS if necessary
# CORS headers (Optiona?)
- "traefik.http.middlewares.cors.headers.accesscontrolallowmethods=*"
- "traefik.http.middlewares.cors.headers.accesscontrolalloworigin=*"
- "traefik.http.middlewares.cors.headers.accesscontrolmaxage=100"
- "traefik.http.middlewares.cors.headers.addvaryheader=true"
When I test my setup with 'https://lojewski.link/shlink/rest/health'
I get the following access log message:
"GET /shlink/rest/health HTTP/2.0" 404 94 "-" "-" 274 "welcome-page@docker" "http://172.20.1.3:80" 6ms
Any ideas on why the routing doesn't work?
Another idea was to use the following rule (not sure if it makes sense and can catch /s
without catching /scss
) in case I want to use the path prefix /s
which could pose problems with files like scss
etc.
Host(`NAME.link`) && (Path(`/s`) || PathPrefix(`/s/`))