Hello everybody !
I've been encountering an issue with Traefik where a defined middleware is not being recognized. I would greatly appreciate any insights or suggestions.
The https://
works well but if I go on http://
I get an 404 page.
Here's my traefik.toml
configuration:
# EntryPoints definition
[entryPoints]
[entryPoints.web]
address = ":80"
[entryPoints.websecure]
address = ":443"
# Providers configuration
[providers]
[providers.docker]
endpoint = "unix:///var/run/docker.sock"
exposedByDefault = false
# Let's Encrypt Certificate Resolver
[certificatesResolvers.letsencrypt.acme]
email = "my@email.fr"
storage = "/etc/traefik/acme.json"
[certificatesResolvers.letsencrypt.acme.httpChallenge]
entryPoint = "web"
# Middleware
[http.middlewares]
[http.middlewares.https-redirect.redirectScheme]
scheme = "https"
here is my Traefik Docker Container configuration in Terraform:
// Ressource pour l'image Docker Traefik
resource "docker_image" "traefik_image" {
name = "traefik:v2.10" // nom de l'image Docker
}
resource "docker_container" "traefik" {
name = "traefik"
image = docker_image.traefik_image.image_id
command = [
"--api.insecure=true --providers.docker",
"--api.dashboard=true",
"--providers.docker.exposedbydefault=false"]
ports {
internal = 443
external = 443
}
ports {
internal = 80
external = 80
}
volumes {
container_path = "/etc/traefik/traefik.toml"
host_path = "/etc/traefik/traefik.toml"
}
volumes {
container_path = "/var/run/docker.sock"
host_path = "/var/run/docker.sock"
read_only = true
}
}
And here's the relevant part of my Terraform configuration for the WordPress Docker container:
resource "docker_container" "fnsf_wordpress_container" {
...
labels {
label = "traefik.enable"
value = "true"
}
labels {
label = "traefik.http.routers.fnsf_wordpress.rule"
value = "Host(`my.domain.fr`)"
}
labels {
label = "traefik.http.services.fnsf_wordpress.loadbalancer.server.port"
value = "80"
}
labels {
label = "traefik.http.routers.fnsf_wordpress.entrypoints"
value = "websecure"
}
labels {
label = "traefik.http.routers.fnsf_wordpress.tls.certresolver"
value = "letsencrypt"
}
labels {
label = "traefik.http.routers.fnsf_wordpress.middlewares"
value = "https-redirect"
}
...
}
The problem is that I keep getting the following error in the Traefik logs:
level=info msg="Configuration loaded from file: /etc/traefik/traefik.toml"
level=error msg="middleware \"https-redirect@docker\" does not exist" routerName=fnsf_wordpress@docker entryPointName=websecure
level=error msg="middleware \"https-redirect@docker\" does not exist" entryPointName=websecure routerName=fnsf_wordpress@docker
level=error msg="middleware \"https-redirect@docker\" does not exist" routerName=fnsf_wordpress@docker entryPointName=websecure
level=error msg="middleware \"https-redirect@docker\" does not exist" entryPointName=websecure routerName=fnsf_wordpress@docker
2023/08/25 17:21:38 reverseproxy.go:667: httputil: ReverseProxy read error during body copy: unexpected EOF
2023/08/25 17:35:37 reverseproxy.go:667: httputil: ReverseProxy read error during body copy: unexpected EOF
Even though I've clearly defined the middleware in the traefik.toml
file. Does anyone have any idea why the middleware might not be recognized? Any help would be greatly appreciated!
Thank you in advance.