I read almost all threads in this forum and outside about accessing dashboard on HTTPS.
Note: I'm using Kamal, so the setup below may be slightly different than the standard Traefik, but I believe the concepts remain the same.
I successfully configured Traefik as a dynamic, transparent/TLS pass-through reverse proxy and load balancer on Linode. Behind the load balancer (IP 1x9.1y4.1z1.121
) there are a couple of backend servers (including one with IP 1x2.1y4.2x4.79
) that seem to properly work as expected (redirection, SSL certificate generation, etc.).
However, I cannot access the Traefik dashboard in secure mode.
Here is the configuration:
# deploy.yml
# ...
# Configure custom arguments for Traefik
traefik:
options:
publish:
- "443:443"
- "8080:8080"
volume:
- "/letsencrypt/acme.json:/letsencrypt/acme.json"
args:
entryPoints.web.address: ":80"
entryPoints.websecure.address: ":443"
entryPoints.web.forwardedHeaders.trustedIPs: "1x9.1y4.1z1.121,127.0.0.1/32,1x2.1y8.2z5.0/24"
entryPoints.web.proxyProtocol.trustedIPs: "1x9.1y4.1z1.121,127.0.0.1/32,1x2.1y8.2z5.0/24"
entryPoints.websecure.forwardedHeaders.trustedIPs: "1x9.1y4.1z1.121,127.0.0.1/32,1x2.1y8.2z5.0/24"
entryPoints.websecure.proxyProtocol.trustedIPs: "1x9.1y4.1z1.121,127.0.0.1/32,1x2.1y8.2z5.0/24"
certificatesresolvers.letsencrypt.acme.email: "my@email.com"
certificatesresolvers.letsencrypt.acme.storage: "/letsencrypt/acme.json"
certificatesresolvers.letsencrypt.acme.dnschallenge: true
certificatesresolvers.letsencrypt.acme.dnschallenge.provider: linode
api.dashboard: true
api.insecure: false
labels:
# Dashboard configuration (not working)
traefik.enable: "true"
traefik.http.routers.dashboard.tls: true
traefik.http.routers.dashboard.rule: Host(`traefik.mywebsite.com`) # (Host(`www.traefik.mywebsite.com`) || Host(`traefik.mywebsite.com`)) && (PathPrefix(`/api`) || PathPrefix(`/dashboard`))
traefik.http.routers.dashboard.service: "api@internal"
traefik.http.routers.dashboard.middlewares: "auth"
traefik.http.middlewares.auth.basicauth.users: test:$2y$05$H2o72tMaO.TwY1wNQUV1K.fhjRgLHRDWohFvUZOJHBEtUXNKrqUKi
env:
secret:
- LINODE_TOKEN
clear:
LINODE_EMAIL: "my@email.com"
# Deploy to these servers.
servers:
web:
hosts:
- 1x2.1y4.2z4.79
options:
"add-host": host.docker.internal:172.17.0.1
labels:
traefik.http.routers.www_mywebsite_com.rule: Host(`www.mywebsite.com`) || Host(`mywebsite.com`)
traefik.http.routers.www_mywebsite_com.middlewares: addhttpswww
traefik.http.routers.www_mywebsite_com_secure.rule: Host(`www.mywebsite.com`) || Host(`mywebsite.com`)
traefik.http.routers.www_mywebsite_com_secure.middlewares: addhttpswww
traefik.http.routers.www_mywebsite_com_secure.tls: true
traefik.http.routers.www_mywebsite_com_secure.tls.certresolver: letsencrypt
traefik.http.routers.www_mywebsite_com_secure.tls.domains[0].main: "mywebsite.com"
traefik.http.routers.www_mywebsite_com_secure.tls.domains[0].sans: "*.mywebsite.com"
traefik.http.middlewares.addhttpswww.redirectregex.regex: ^(?:http|https)://(?:www\.)?(.*)
traefik.http.middlewares.addhttpswww.redirectregex.replacement: "https://www.$1"
# ...
Using the above configuration, I tried accessing the dashboard without success at URLs like:
http://traefik.mywebsite.com:8080/
> This site can’t be reachedhttps://traefik.mywebsite.com:8080/
> This site can’t be reachedhttp://www.traefik.mywebsite.com:8080/
> This site can’t be reachedhttps://www.traefik.mywebsite.com:8080/
> This site can’t be reachedhttp://traefik.mywebsite.com/dashboard/
> This site can’t be reachedhttps://traefik.mywebsite.com/dashboard/
> This site can’t be reachedhttp://www.traefik.mywebsite.com/dashboard/
> This site can’t be reachedhttps://www.traefik.mywebsite.com/dashboard/
> This site can’t be reachedhttp://mywebsite.com:8080/
> This site can’t be reachedhttp://www.mywebsite.com:8080/
> This site can’t be reachedhttps://mywebsite.com:8080/
> This site can’t be reachedhttps://www.mywebsite.com:8080/
> This site can’t be reachedhttp://1x2.1y4.2z4.79:8080/dashboard/
> This site can’t be reachedhttps://1x2.1y4.2z4.79:8080/dashboard/
> This site can’t be reached
When I use api.insecure: true
then the only URLs that work for accessing the dashboard are:
http://1x2.1y4.2z4.79:8080/
> Works but in insecure modehttp://1x2.1y4.2x4.79:8080/dashboard/
Works but in insecure mode
Here is the dashboard in insecure mode:
Here is the routers detail:
What am I missing? Do I need another piece of middleware to perform some sort of redirect/mapping?