Traefik returns error 404 on http requests

Issue

I have a traefik reverse proxy instance running inside docker on linux. I have the issue that traefik always returns 404 on http requests but not on https requests. Https requests are working without any issue.

This is my docker-compose.yml:

    version: '3'
    
    services:
      ucp:
        image: ghcr.io/rp-projekt/rp-server/ucp:main
        volumes:
          - /home/docker/ucp/.env:/usr/src/app/.env
        networks:
          - rp
        restart: unless-stopped
        extra_hosts:
          - "docker.host.internal:host-gateway"
          - "host.docker.internal:host-gateway"
        labels:
          - "traefik.enable=true"
          - "traefik.http.middlewares.redir-https.redirectscheme.scheme=https"
          - "traefik.http.middlewares.redir-https.redirectscheme.permanent=true"
          - "[email protected]"
          - "traefik.http.routers.ucp.tls.certresolver=le"
          - "traefik.http.routers.ucp.rule=Host(`ucp.roestipommes.de`)"
          - "traefik.http.routers.ucp.entrypoints=web,websecure"
          - "traefik.http.services.ucp.loadbalancer.server.port=80"
          - "traefik.http.routers.ucp.service=ucp"
    networks:
      rp:
        external: true

My traefik config:

entryPoints:
  web:
    address: ":80"
    forwardedHeaders:
      trustedIPs:
        - "127.0.0.1/32"
        - "172.16.0.0/12"
        - "10.0.0.0/8"
        - "192.168.0.0/16"
  websecure:
    address: ":443"
    forwardedHeaders:
      trustedIPs:
        - "127.0.0.1/32"
        - "172.16.0.0/12"
        - "10.0.0.0/8"
        - "192.168.0.0/16"
providers:
  file:
    filename: /dynamic_config.yaml
  docker:
    exposedbydefault: False

certificatesResolvers:
  le:
    acme:
      email: hidden
      httpChallenge:
        entryPoint: web

Solution

I solved this issue by creating two seperate routers for http and https.

Answered By – Nils van Lück

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published