# Help with 404 error

**URL:** <https://community.traefik.io/t/help-with-404-error/21520>\
**Category:** Traefik v2\
**Tags:** letsencrypt-acme, docker, middleware\
**Created:** [February 15, 2024, 6:05pm UTC](https://community.traefik.io/t/help-with-404-error/21520 "2024-02-15T18:05:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 15, 2024, 6:05pm UTC](https://community.traefik.io/t/help-with-404-error/21520/1 "2024-02-15T18:05:33Z")

</div>

Having trouble with a 404 page not found error with traefik / docker, getting it with hostname and ip address (local & public). A & CNAME records configured in Cloudflare (currently grey mode). Port forwarding on router to server for 8008 (http) and 8443 (https) because 80 & 443 are already taken on network by other server.

Confirmed with `cn -vz x.x.x.x port` that ports are open and available:

```auto

Connection to 192.168.0.201 port 8443 [tcp/pcsync-https] succeeded!

Connection to 1.2.3.4 port 8443 [tcp/pcsync-https] succeeded!

Connection to traefik.domain.com port 8443 [tcp/pcsync-https] succeeded!

```

Not sure what I’m screwing up and where exactly, so hopefully my configs below will give more insights. Also adding pastebin for [traefik.log here](https://pastebin.com/Ax3Kyjyu).

Hope someone can point me in the right direction? Thx!

**docker-compose.yml**

```auto
version: "3.9"

services:
  traefik:
    image: traefik:v2.10
    container_name: traefik
    restart: always
    networks:
      - proxy
    ports:
      - 8008:80
      - 8443:443
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - $DOCKERDIR/appdata/traefik/traefik.yml:/traefik.yml:ro
      - $DOCKERDIR/appdata/traefik/configs:/configs:ro
      - $DOCKERDIR/appdata/traefik/acme/acme.json:/acme.json:rw
      - $DOCKERDIR/appdata/traefik/logs:/logs:rw
    environment:
      - CF_DNS_API_TOKEN=${CLOUDFLARE_DNS_API}
      - TRAEFIKADMIN=${TRAEFIKADMIN}
    read_only: true
    security_opt:
      - no-new-privileges=true
    labels:
      - traefik.enable=true
      - traefik.http.routers.traefik-https.entrypoints=https
      - traefik.http.routers.traefik-https.rule=Host(`traefik.domain.com`)
      - traefik.http.middlewares.traefik-auth.basicauth.users={$TRAEFIKADMIN}
      - traefik.http.routers.traefik-https.middlewares=traefik-auth
      - traefik.http.routers.traefik-https.service=api@internal
      - traefik.http.routers.traefik-https.tls.certresolver=letsencrypt
      - traefik.http.routers.traefik-https.tls.domains[0].main=domain.com
      - traefik.http.routers.traefik-https.tls.domains[0].sans=*.domain.com

networks:
  proxy:
    external: {}

```

**traefik.yml**

```auto
api:
 dashboard: true

entryPoints:
  http:
    address: ":80"
    forwardedHeaders:
      trustedIPs:
        - "127.0.0.1/32"
        - "10.0.0.0/8"
        - "192.168.0.0/16"
        - "172.16.0.0/12"
  https:
    address: ":443"
    http:
      tls:
        certResolver: letsencrypt
    forwardedHeaders:
      trustedIPs:
        - "127.0.0.1/32"
        - "10.0.0.0/8"
        - "192.168.0.0/16"
        - "172.16.0.0/12"

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
    defaultRule: "Host(`{{ index .Labels \"com.docker.compose.service\”}}.domain.com`)"
    network: proxy
  file:
    directory: "/configs"
    watch: true

certificatesResolvers:
  http:
    acme:
      email: usr@domain.com
      storage: acme.json
      httpChallenge:
        entryPoint: http
  letsencrypt:
    acme:
      caServer: "https://acme-staging-v02.api.letsencrypt.org/directory"
      email: usr@domain.com
      storage: acme.json
      dnsChallenge:
        provider: cloudflare
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

serversTransport:
    insecureSkipVerify: false

accessLog:
  filePath: "/logs/access.log"
  fields:
    headers:
      names:
        User-Agent: keep

log:
  filePath: "/logs/traefik.log"
  level: DEBUG

```

**middlewares.yml**

```auto
http:
  middlewares:
    traefik-auth:
      basicAuth:
        users:
          - “usr:password”

```

**tsl.yml**

```auto
tls:
  options:
    default:
      minVersion: VersionTLS12
      cipherSuites:
       - "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256"
       - "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384"
       - "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305"
       - "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"
       - "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384"
       - "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305"

```

**.env**

```auto
USERDIR="/home/usr”
DOCKERDIR="/home/usr/docker"
DATADIR="/mnt/storage"
#DOMAINNAME_CLOUD_SERVER=domain.com
#CLOUDFLARE_EMAIL=usr@domain.com
#CLOUDFLARE_API_KEY=@@@@@
CLOUDFLARE_DNS_API=@@@@@
#LOCAL_IPS=127.0.0.1/32,10.0.0.0/8,192.168.0.0/16,172.16.0.0/12
#CLOUDFLARE_IPS=173.245.48.0/20,103.21.244.0/22,103.22.200.0/22,103.31.4.0/22,141.101.64.0/18,108.162.192.0/18,190.93.240.0/20,188.114.96.0/20,197.234.240.0/22,198.41.128.0/17,162.158.0.>
TRAEFIKADMIN=usr:@@@@@

```

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [February 15, 2024, 10:13pm UTC](https://community.traefik.io/t/help-with-404-error/21520/2 "2024-02-15T22:13:52Z")

</div>

> [@sucre182](#):
>
> Having trouble with a 404 page not found

How about you share which page (URL) you try to request?

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 16, 2024, 3:54pm UTC](https://community.traefik.io/t/help-with-404-error/21520/3 "2024-02-16T15:54:13Z")

</div>

> [@bluepuma77](#):
>
> How about you share which page (URL) you try to request?

Sure, here you go: [https://traefik.continental34.com:8443](https://traefik.continental34.com:8443)

Adding 8443 to avoid nginx that's running on 443 port other server.

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [February 16, 2024, 3:58pm UTC](https://community.traefik.io/t/help-with-404-error/21520/4 "2024-02-16T15:58:47Z")

</div>

You are trying to reach the dashboard ([doc](https://doc.traefik.io/traefik/master/operations/dashboard/#the-dashboard))?

> The dashboard is available at the same location as the [API](https://doc.traefik.io/traefik/master/operations/api/) but on the path `/dashboard/` by default.  
> The trailing slash `/` in `/dashboard/` is mandatory

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 16, 2024, 4:53pm UTC](https://community.traefik.io/t/help-with-404-error/21520/5 "2024-02-16T16:53:01Z")

</div>

Thx starting to get somewhere, I'm getting the sign in prompt. But my credentials don't seem to work:

```auto
time="2024-02-16T17:44:12+01:00" level=debug msg="Authentication failed" middlewareName=traefik-auth@docker middlewareType=BasicAuth

```

Using the credentials provided in middlewares.yml listed in original post above. Any idea what I'm screwing up?

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [February 16, 2024, 4:57pm UTC](https://community.traefik.io/t/help-with-404-error/21520/6 "2024-02-16T16:57:01Z")

</div>

Check the [BasicAuth middlewares doc](https://doc.traefik.io/traefik/middlewares/http/basicauth/):

> Passwords must be hashed using MD5, SHA1, or BCrypt.

> Tip: Use `htpasswd` to generate the passwords

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 16, 2024, 5:51pm UTC](https://community.traefik.io/t/help-with-404-error/21520/7 "2024-02-16T17:51:39Z")

</div>

So I re-issued the password via htpasswd, but still bumping into same issue. Think I've located the problem. I've got the user:passwd set in middlewares.yml, but also calling $TRAEFIKADMIN from .env file (later slightly differs, using double $$ variables in password string of .env).

in labels docker-compose.yml I've got this:

```auto
      - traefik.http.middlewares.traefik-auth.basicauth.users={$TRAEFIKADMIN}
      - traefik.http.routers.traefik-https.middlewares=traefik-auth

```

What's the recommended way to fix this? Thx for your guidance @bluepuma77

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [February 16, 2024, 10:39pm UTC](https://community.traefik.io/t/help-with-404-error/21520/8 "2024-02-16T22:39:59Z")

</div>

Test it step by step, place your username and hash directly in the compose file, without templating using vars.

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 18, 2024, 7:59pm UTC](https://community.traefik.io/t/help-with-404-error/21520/9 "2024-02-18T19:59:33Z")

</div>

Hitting a wall here, tried all sort of variants. Got this now in label compose:

```auto
    labels:
      - traefik.enable=true
      - traefik.http.routers.traefik-https.entrypoints=https
      - traefik.http.routers.traefik-https.rule=Host(`traefik.continental34.com`)
      - traefik.http.routers.traefik-https.middlewares=traefik-auth
      - traefik.http.middlewares.traefik-auth.basicauth.users=usr:$$1234$$5678$$9123456789
      - traefik.http.routers.traefik-https.service=api@internal
      - traefik.http.routers.traefik-https.tls.certresolver=letsencrypt
      - traefik.http.routers.traefik-https.tls.domains[0].main=continental34.com
      - traefik.http.routers.traefik-https.tls.domains[0].sans=*.continental34.com

```

And in middlewares.yml:

```auto
http:
  middlewares:
    traefik-auth:
      basicAuth:
        users:
          - "usr:$1234$5678$9123456789"

```

Now I'm not even getting a login screen anymore, just goes straight to 404... Any clue?

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [February 18, 2024, 10:26pm UTC](https://community.traefik.io/t/help-with-404-error/21520/10 "2024-02-18T22:26:59Z")

</div>

Did you try  
`https://traefik.continental34.com/dashboard/`?

Why do you define the basicauth twice (in labels and dynamic config)?

Why do you define wildcards in the router for a single domain?

Why don’t you enable Traefik debug log ([doc](https://doc.traefik.io/traefik/observability/logs/#level)) to check what’s happening?

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 19, 2024, 11:37am UTC](https://community.traefik.io/t/help-with-404-error/21520/11 "2024-02-19T11:37:19Z")

</div>

Removed the middlewares.yml and its working now in Chrome, thx @bluepuma77 _solved the safari issue in meantime mentioned in original reply_

Already had debug log enabled, now seeing a bunch of issues with cert & TLS, [here's the pastebin.](https://pastebin.com/LTeAZsvg)

Grabbed the wildcard part from another tutorial, no specific reason tbh. What do you recommend to do with those last two lines in label section? Remove wildcard and adjust into this?

```auto
- traefik.http.routers.traefik-https.tls.domains[0].main=traefik.continental34.com

```

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 19, 2024, 2:00pm UTC](https://community.traefik.io/t/help-with-404-error/21520/12 "2024-02-19T14:00:33Z")

</div>

mmm still having trouble with the basic authentication. Apparently it's not picking up the authentication at all when I define it as following in docker config:

```auto
 - traefik.http.middlewares.traefik-auth.basicauth.users=usr:$$1234$$5678$$9123456789

```

When I re-add the label below the login request appears again, but the user and password defined in label above are not accepted (getting new login request each time).

```auto
- traefik.http.routers.traefik-https.middlewares=traefik-auth

```

Any suggestions?

---

<div class="post-metadata">

**Author:** ![bluepuma77](https://avatars.discourse-cdn.com/v4/letter/b/a9adbd/32.png) [@bluepuma77](https://community.traefik.io/u/bluepuma77)\
**Post date:** [February 19, 2024, 2:40pm UTC](https://community.traefik.io/t/help-with-404-error/21520/13 "2024-02-19T14:40:09Z")

</div>

Here is a working configuration, take it from there: [simple Traefik example](https://github.com/bluepuma77/traefik-best-practice/tree/main/docker-traefik-dashboard-letsencrypt).

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [February 20, 2024, 12:42pm UTC](https://community.traefik.io/t/help-with-404-error/21520/14 "2024-02-20T12:42:32Z")

</div>

Ok so went back to basics and using the config from simple traefik example, see config below. Unfortunately still getting the same login loop issue. [Here's the debug output of traefik.log](https://pastebin.com/nWmzy34z).

Where to take it from here?

```auto
version: '3.9'

services:
  traefik:
    image: traefik:v3.0
    container_name: traefik
    restart: always
    ports:
      - 8008:80
      - 8443:443
    networks:
      - proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - letsencrypt:/letsencrypt
      - ./appdata/traefik/logs:/logs
      - /etc/localtime:/etc/localtime:ro

    command:
      - --api.dashboard=true
      - --log.level=DEBUG
      - --log.filepath=/logs/traefik.log
      - --accesslog=true
      - --accesslog.filepath=/logs/access.log
      - --providers.docker.network=proxy
      - --providers.docker.exposedByDefault=false
      - --entrypoints.web.address=:80
      - --entrypoints.web.http.redirections.entrypoint.to=websecure
      - --entryPoints.web.http.redirections.entrypoint.scheme=https
      - --entrypoints.websecure.address=:443
      - --entrypoints.websecure.asDefault=true
      - --entrypoints.websecure.http.tls.certresolver=letsencrypt
      - --certificatesresolvers.myresolver.acme.email=usr@continental34.com
      - --certificatesresolvers.myresolver.acme.tlschallenge=true
      - --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json

    labels:
      - traefik.enable=true
      - traefik.http.routers.mydashboard.rule=Host(`traefik.continental34.com`)
      - traefik.http.routers.mydashboard.service=api@internal
      - traefik.http.routers.mydashboard.middlewares=myauth
      - traefik.http.middlewares.myauth.basicauth.users=usr:$$apr1$$2345$$6789

networks:
  proxy:
    name: proxy

volumes:
  letsencrypt:
    name: letsencrypt

```

---

<div class="post-metadata">

**Author:** ![sucre182](https://avatars.discourse-cdn.com/v4/letter/s/f0a364/32.png) [@sucre182](https://community.traefik.io/u/sucre182)\
**Post date:** [April 11, 2024, 6:17am UTC](https://community.traefik.io/t/help-with-404-error/21520/15 "2024-04-11T06:17:10Z")

</div>

[The solution](https://community.traefik.io/t/basicauth-login-issue/21604/13) was simple. I was using the hash instead of the actual password, therefore the authentication failed 🥸

thx for your patience @bluepuma77

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/containo/original/2X/b/bd81ebdb578656e76e56ff3cc3eed021d3ba132d.png) [@system](https://community.traefik.io/u/system)\
**Post date:** [April 14, 2024, 6:17am UTC](https://community.traefik.io/t/help-with-404-error/21520/16 "2024-04-14T06:17:33Z")

</div>

Closed on April 14, 2024, 6:17am UTC

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