Errors middleware not redirecting to the right page of service

Hello,
I have troubles adding error redirection on my Traefik Docker setup. For now, I only try to redirect 404 errors. Redirection works but redirects to Nginx main page (index.html) instead of 404.html (which is working on direct access).

Here is my docker compose file (contains Jinja2 variables as I'm deploying it with Ansible),

version: "3.7"

services:
  application:
    container_name: Traefik
    image: traefik
    configs:
      - source: "{{ Traefik_Docker_configuration_name }}"
        target: "{{ Traefik_configuration_file_destination_path_inside_container }}"
      - source: "{{ Traefik_dynamic_configuration_Docker_name }}"
        target: "{{ Traefik_dynamic_configuration_file_destination_path_inside_container }}"
    cap_drop:
      - ALL
    deploy:
      restart_policy:
        condition: on-failure
      labels:
        traefik.enable: "true"

        traefik.http.routers.traefik_dashboad.rule: Host(`{{ Traefik_dashboard_FQDN }}`)
        traefik.http.routers.traefik_dashboad.service: api@internal
        traefik.http.routers.traefik_dashboad.entrypoints: websecure

        traefik.http.routers.traefik_dashboad.middlewares: basic_HTTP_authentication

        traefik.http.middlewares.basic_HTTP_authentication.basicauth.users: tigerblue77:$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$

        traefik.http.services.traefik_application.loadbalancer.server.port: 443
    restart: unless-stopped
    environment:
      PUID: "1000" # For security reasons : https://docs.linuxserver.io/general/understanding-puid-and-pgid
      PGID: "1000" # For security reasons : https://docs.linuxserver.io/general/understanding-puid-and-pgid
      TZ: "{{ server_time_zone }}"
    volumes:
      - "{{ Traefik_Docker_SSL_certificates_volume_name }}:/letsencrypt"
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
    ports:
      - target: {{ Traefik_Docker_container_HTTP_port_to_expose }}
        published: {{ Traefik_Docker_container_HTTP_port_to_expose }}
        mode: ingress
      - target: {{ Traefik_Docker_container_HTTPS_port_to_expose }}
        published: {{ Traefik_Docker_container_HTTPS_port_to_expose }}
        mode: ingress
    networks:
      - "{{ Docker_DMZ_network_name }}"

  HTTP_errors_handler:
    container_name: Traefik_HTTP_errors_handler
    image: nginx
    deploy:
      restart_policy:
        condition: on-failure
      labels:
        # enable Traefik for this service
        traefik.enable: "true"
        traefik.docker.network: "{{ Docker_DMZ_network_name }}"

        # router (catches all requests with lowest possible priority)
        traefik.http.routers.error-router.rule: "HostRegexp(`{catchall:.*}`)"
        traefik.http.routers.error-router.priority: "1"
        traefik.http.routers.error-router.middlewares: "error-pages-middleware"

        # middleware
        traefik.http.middlewares.error-pages-middleware.errors.status: "404"
        traefik.http.middlewares.error-pages-middleware.errors.service: "error-pages-service"
        traefik.http.middlewares.error-pages-middleware.errors.query: "/{status}.html"

        # service
        traefik.http.services.error-pages-service.loadbalancer.server.port: "80"
    restart: unless-stopped
    volumes:
      - "/var/lib/docker/volumes/Traefik_HTTP_error_pages/_data/404.html:/usr/share/nginx/html/404.html"
      - "{{ Nginx_config_Docker_volume_name }}:/etc/nginx/conf.d/"
    ports:
      - "{{ Nginx_Docker_container_HTTP_port_to_expose }}:80"
    networks:
      - "{{ Docker_DMZ_network_name }}"

configs:
  {{ Traefik_Docker_configuration_name }}:
    name: {{ Traefik_Docker_configuration_name }}
    file: {{ Traefik_configuration_file_destination_path }}
    # external: true
  {{ Traefik_dynamic_configuration_Docker_name }}:
    name: {{ Traefik_dynamic_configuration_Docker_name }}
    file: {{ Traefik_dynamic_configuration_file_destination_path }}
    # external: true

volumes:
  {{ Traefik_Docker_SSL_certificates_volume_name }}:
  {{ Traefik_HTTP_error_pages_volume_name }}:
  {{ Nginx_config_Docker_volume_name }}:

networks:
  {{ Docker_DMZ_network_definition }}

Nothing special in logs, except warnings which are linked to what I'm adding (any advice to remove them is welcome) :

time="2023-11-30T19:34:44+01:00" level=info msg="Configuration loaded from file: /etc/traefik/traefik.yml"
2023-11-30T19:34:44+01:00 INF | msg=Traefik version 2.10.6 built on 2023-11-28T14:52:13Z 
2023-11-30T19:34:44+01:00 INF | msg=Stats collection is enabled. 
2023-11-30T19:34:44+01:00 INF | msg=Many thanks for contributing to Traefik's improvement by allowing us to receive anonymous information from your configuration. 
2023-11-30T19:34:44+01:00 INF | msg=Help us improve Traefik by leaving this feature on :) 
2023-11-30T19:34:44+01:00 INF | msg=More details on: https://doc.traefik.io/traefik/contributing/data-collection/ 
2023-11-30T19:34:44+01:00 INF | msg=Starting provider aggregator aggregator.ProviderAggregator 
2023-11-30T19:34:44+01:00 INF | msg=Starting provider *file.Provider 
2023-11-30T19:34:44+01:00 INF | msg=Starting provider *traefik.Provider 
2023-11-30T19:34:44+01:00 INF | msg=Starting provider *docker.Provider 
2023-11-30T19:34:44+01:00 INF | msg=Starting provider *acme.ChallengeTLSALPN 
2023-11-30T19:34:44+01:00 INF | msg=Starting provider *acme.Provider 
2023-11-30T19:34:44+01:00 INF | ACME CA=https://acme-v02.api.letsencrypt.org/directory msg=Testing certificate renew... providerName=letsencrypt.acme 
2023-11-30T19:35:05+01:00 warning | entryPointName=websecure msg=No domain found in rule HostRegexp(`{catchall:.*}`), the TLS options applied for this router will depend on the SNI of each request routerName=websecure-error-router@docker 
2023-11-30T19:37:04+01:00 warning | entryPointName=websecure msg=No domain found in rule HostRegexp(`{catchall:.*}`), the TLS options applied for this router will depend on the SNI of each request routerName=websecure-error-router@docker 

Thanks for your help

Hey guys! Any suggestions? Thanks in advance!

Share your full Traefik static and dynamic config.

Where is the service you want to apply the error redirect to? You test on the error-page-server itself?

Update your double quotes to match doc:

# Dynamic Custom Error Page for 5XX Status Code
labels:
  - "traefik.http.middlewares.test-errors.errors.status=500,501,503,505-599"
  - "traefik.http.middlewares.test-errors.errors.service=serviceError"
  - "traefik.http.middlewares.test-errors.errors.query=/{status}.html"

Hello,
After hours or searches, found my -stupid- mistake : I was not applying the middleware on docker containers that Traefik is exposing...
However, the documentation of this part should be improved, it's not clear at all..

Thanks for your help !