Traefik v2 error 404

Hello, I come here because it's been a while since I've been able to solve my problems so last hope! and thanks to those who will help me

I can't find my url, I get a 404 page not found each time unfortunately

here is the configuration of my files (git-rule.toml, traefik.toml, docker-compose.yml) :

git-rule.toml

[http.routers]
  # Dedicated router for Yeswecan SCM.
  [http.routers.project]
    entryPoints = ["web"]
    middlewares = ["https_redirect"]
    rule = "Host(`project.yeswecan.fr`)"
    service = "project"
    # Using main certResolver conf. to request a certificate; declared in traefik.toml.
    [http.routers.project.tls]
      certResolver = "dedicated"

[http.services]
  # Dedicated service for Yeswecan SCM (GitLab).
  [http.services.project]
    [[http.services.project.loadBalancer.servers]]
      url = "http://192.168.1.40"

traefik.toml

# Main entryPoints definition block.
[entryPoints]
  [entryPoints.web]
     address = ":80"
   [entryPoints.websecure]
     address = ":443"

# SSL/TLS certificate configuration block; provided by Let's encrypt.
[certificatesResolvers.dedicated.acme]
  email = "matteo@yeswecan.fr"
  storage = "/etc/traefik/acme/acme.json"
  caServer = "https://acme-v02.api.letsencrypt.org/directory"
  # Cert. validation made through http challenge and "web" entryPoint.
  [certificatesResolvers.dedicated.acme.httpChallenge]
   entryPoint = "web"

[providers]
  [providers.file]
    directory = "/etc/traefik/"
    watch = true

[log]
  filePath = "/var/log/traefik/traefik.log"
  format = "common"

# Traefik API is enabled.
[api]
  dashboard = true # Dashboard is available only "locally" (Yeswecan internal network)
  insecure = true # No authentication on dashboard

# Main middlewares configuration block.
[http.middlewares]
  # Traffic redirection from every router calling this middleware (http ---> https).
  [http.middlewares.https_redirect.redirectScheme]
    scheme = "https"
    permanent = true

docker-compose.yml

version: '3.3'

services:
  reverse-proxy:
    image: traefik:v2.1.3
    container_name: "traefik"
    command:
      - "--api.insecure=true"
      - "--certificatesresolvers.dedicated.acme.httpchallenge=true"
      - "--certificatesresolvers.dedicated.acme.httpchallenge.entrypoint=web"
      - "--certificatesresolvers.dedicated.acme.email=matteo@yeswecan.fr"
      - "--certificatesresolvers.dedicated.acme.storage=/etc/traefik/acme/acme.json"
      - "--entrypoints.web.address=:80"
      - "--entrypoints.websecure.address=:443"
      - "--entrypoints.api.address=:8080"
      - "--log.level=DEBUG"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"

    ports:
      - "80:80"     # The HTTP port
      - "8080:8080" # The Web UI (enabled by --api)
      - "443:443"   # The HTTPS port
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
      - ./traefik.toml:/etc/traefik/traefik.toml
      - ./rules:/etc/traefik/rules
      - ./acme/acme.json:/etc/traefik/acme/acme.json
      - ./log:/var/log/traefik

Hello @PKXL

I deployed your configuration on my local environment and I found that entry point WEB has not been started:

time="2021-03-05T12:17:14Z" level=error msg="entryPoint \"web\" doesn't exist" routerName=project@file entryPointName=web
time="2021-03-05T12:17:14Z" level=error msg="no valid entryPoint for this router" routerName=project@file

It happened because of the overwritten configuration. Traefik loads the configuration in the following order:

  • File
  • Flags (CLI command)
  • Environment variables

Here is the code which is responsible for that: traefik/traefik.go at master · traefik/traefik · GitHub

See also our official docs: Configuration Introduction - Traefik | Site | v2.4

A few good practices:

  1. As it is written in the documentation use only one source for static configuration. Don't mix CLI commands with config file or environment variables. Thus, I suggest moving entrypoints from the command section to traefik.toml file.

  2. I also suggest grouping config section e.g. log level Debug has been configured through command and then in TOML file. Let's try to keep that in one config provider .e.g in TOML file.

  3. Regarding routers I suggest creating two routers: one for HTTP and the second routers for HTTPS. On the HTTP router you can create a redirection from HTTP to HTTPS and on the HTTPS router you can add TLS configuration

  4. Enableing api.insecure=true automatically starts internal entrypoint called Traefik on 8080/TCP inside a container, so no need to enable a dedicated API entry point. Actually, it won't start and will throw an error that can't bind to the 8080 port.

  5. I highly recommend upgrading Traefik to the latest version, for today it is 2.4.6

Hope that helps. Please let us know the results of your deployment.

1 Like

Thanks a lot mister !

it was due to a confusion of redirection to websecure in my traefik.toml file !
:grinning:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.