I'm trying to restrict a http path so that only users authorised using mtls will be able to see the path.
At the bottom are the settings which is a combination of docker labels and dynamic configuration files.
A side note is when each of the routes are individually run the work as expected but getting them to work together is stumping me.
Thanks for any help.
When running the configuration below:
The browser without the certificate is causing the following error and not show either "localhost" or "localhost/restricted" and raises the following error.
'time="2021-05-18T08:46:23Z" level=debug msg="http: TLS handshake error from 127.0.0.1:49660: remote error: tls: bad certificate"
The browers with the certificate is working as expected
The dashboard the following error for the "localhost" route is shown Host(
localhost): unknown TLS options: website@file
If I remove the traefik.http.routers.website.tls.options=website@file
line get the following:
The browser without the certificate can access "localhost" and "localhost/restricted"
The brower with the certificate can access "localhost" and "localhost/restricted"
The dashboard has error for both the routers:
found different TLS options for routers on the same host localhost, so using the default TLS options instead
docker labels
# Common configuration
traefik.enable=true
traefik.http.services.website.loadbalancer.server.port=80
# mTLS secured path
traefik.http.routers.secure-website.rule=(Host(`localhost`) && PathPrefix(`/restricted`))
traefik.http.routers.secure-website.tls=true
traefik.http.routers.secure-website.tls.options=secure-website@file
traefik.http.routers.secure-website.service=website
# Main paths
traefik.http.routers.website.rule=Host(`localhost`)
traefik.http.routers.website.tls=true
traefik.http.routers.website.tls.options=website@file
traefik.http.routers.website.service=website
website@file
tls:
certificates:
- certFile: /etc/traefik/storage/server.crt
keyFile: /etc/traefik/storage/server.key
secure-website@file
tls:
certificates:
- certFile: /etc/traefik/storage/server.crt
keyFile: /etc/traefik/storage/server.key
options:
secure-website:
clientAuth:
caFiles:
- /etc/traefik/storage/ca.crt
clientAuthType: RequireAndVerifyClientCert