Hi, I'm playing with Traefik V2, after looking through the documentation, community and general resources on Internet, I've come with the following exercise that unfortunately is not working.
My objective in this exercise is to configure Traefik as a simple reverse proxy doing http-to-https redirection for a back-end web service.
To learn the configurations I'm also trying to keep separate config files (and not putting everything inside the docker-compose.yml as I've seen in many tutorials online)
I've come up with the following
docker-compose.yml:
version: "3.3"
services:
traefik:
image: "traefik:latest"
container_name: "traefik"
ports:
- "80:80"
- "443:443"
- "8080:8080"
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
- "$PWD/traefik.yml:/etc/traefik/traefik.yml"
- "$PWD/providers.yml:/etc/traefik/providers.yml"
whoami:
image: "traefik/whoami"
container_name: "whoami"
labels:
- "traefik.enable=true"
traefik.yml:
log:
level: DEBUG
api:
dashboard: true
insecure: true
providers:
docker:
exposedByDefault: false
file:
filename: "/etc/traefik/providers.yml"
watch: true
entryPoints:
websecure:
address: ":443"
providers.yml:
http:
routers:
to-whoami:
rule: "Host(`myipaddress`)"
entryPoints: web
middlewares: "https-redirect"
service: whoami
redirect-to-https:
rule: "Host(`myipaddress`)"
entryPoints: web
middlewares: "https-redirect"
service: whoami
middlewares:
https-redirect:
redirectScheme:
scheme: "https"
services:
whoami:
loadBalancer:
servers:
- url: "http://whoami"
Where myipaddress is the IP of the server where Docker is running in my local LAN.
The thing is that when I visit http://myipaddress
, I'm redirected to https://myipaddress
but instead of the whoami service I'm presented with a "404 page not found
" error, and I can't understand why.
From Traefik logs, the only thing I see is
level=debug msg="http: TLS handshake error from x.x.x.x:56651: remote error: tls: unknown certificate"
level=debug msg="Serving default certificate for request: \"\""
But I think this could be ignored because I've seen that Traefik generated a self-signed certificate which for this exercise it's fine.
Can you help me in identifying which mistake I've made?