# Traefik docker basic auth for dashboard doesn't work neither redirection to https

**URL:** <https://community.traefik.io/t/traefik-docker-basic-auth-for-dashboard-doesnt-work-neither-redirection-to-https/18329>\
**Category:** Traefik v2\
**Tags:** docker\
**Created:** [April 20, 2023, 9:26am UTC](https://community.traefik.io/t/traefik-docker-basic-auth-for-dashboard-doesnt-work-neither-redirection-to-https/18329 "2023-04-20T09:26:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ginesdelpan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ginesdelpan/32/4991_2.png) [@ginesdelpan](https://community.traefik.io/u/ginesdelpan)\
**Post date:** [April 20, 2023, 9:26am UTC](https://community.traefik.io/t/traefik-docker-basic-auth-for-dashboard-doesnt-work-neither-redirection-to-https/18329/1 "2023-04-20T09:26:33Z")

</div>

hello,

i have the docker-compose.yml that is below and i can connect to [http://localhost:8888](http://localhost:8888), but it does not ask me for any credentials

moreover, when i try to connect to https, i get a 404 error page

any advice would be very appreciated, thank you in advance

```auto
version: '3.3'

networks:
  red_traefik:
    external: true

services:
  traefik:
    image: traefik:v2.9.10
    container_name: "traefik"
    restart: always
    command:
      - "--log.level=DEBUG"
      - "--api.dashboard=true"
      - "--api.insecure=true"
      - "--entrypoints.web_80.address=:80"
      - "--entrypoints.web_443.address=:443"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--certificatesresolvers.midesafiotls.acme.httpchallenge=true"
      - "--certificatesresolvers.midesafiotls.acme.httpchallenge.entrypoint=web_80"
      - "--certificatesresolvers.midesafiotls.acme.email=fulano@ejemplo.com"
      - "--certificatesresolvers.midesafiotls.acme.storage=/letsencrypt/acme.json"

    ports:
      - "80:80"
      - "443:443"
      - "8888:8080"

    labels:
      - "traefik.enable=true"

      # HTTPS Redirect
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web_80"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

      # Dashboard
      - "traefik.http.routers.traefik-router.entrypoints=web_443"
      - "traefik.http.routers.traefik-router.rule=Host(`servidor.ejemplo.com`)"
      - "traefik.http.routers.traefik-router.tls=true"
      - "traefik.http.routers.traefik-router.tls.certresolver=midesafiotls"
      - "traefik.http.routers.traefik-router.service=api@internal"

      # autenticacion
      - "traefik.http.routers.traefik-router.middlewares=dashboardauth"
      - "traefik.http.middlewares.dashboardauth.basicauth.users=gestor:$$apr1$$cLtMckxk$$ZDXcGECjJ6tl.q17BnIrF." 

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./datos_letsencrypt:/letsencrypt
    networks:
      - red_traefik

```

---

<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:** [April 21, 2023, 5:05am UTC](https://community.traefik.io/t/traefik-docker-basic-auth-for-dashboard-doesnt-work-neither-redirection-to-https/18329/2 "2023-04-21T05:05:31Z")

</div>

Remove this line:

> [@ginesdelpan](#):
>
> `- "--api.insecure=true"`

> [Insecure Mode](https://doc.traefik.io/traefik/operations/dashboard/#insecure-mode)  
> This mode is not recommended because it does not allow the use of security features.

You can also compare to this [simple Traefik example](https://github.com/bluepuma77/traefik-best-practice/tree/main/docker-traefik-dashboard-letsencrypt).

---

<div class="post-metadata">

**Author:** ![ginesdelpan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ginesdelpan/32/4991_2.png) [@ginesdelpan](https://community.traefik.io/u/ginesdelpan)\
**Post date:** [April 21, 2023, 11:39am UTC](https://community.traefik.io/t/traefik-docker-basic-auth-for-dashboard-doesnt-work-neither-redirection-to-https/18329/3 "2023-04-21T11:39:28Z")

</div>

tank you for the reply

when i remove the insecure directive, i get the errors:

```auto
$ wget http://127.0.0.1:8888/
--2023-04-21 13:34:27-- http://127.0.0.1:8888/
Connecting to 127.0.0.1:8888... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

--2023-04-21 13:34:28-- (try: 2) http://127.0.0.1:8888/
Connecting to 127.0.0.1:8888... connected.
HTTP request sent, awaiting response... Read error (Connection reset by peer) in headers.
Retrying.

^C

$ wget https://127.0.0.1:8888/
--2023-04-21 13:34:33-- https://127.0.0.1:8888/
Connecting to 127.0.0.1:8888... connected.
OpenSSL: error:0A000126:SSL routines::unexpected eof while reading
Unable to establish SSL connection.

$ wget https://127.0.0.1:8888/
--2023-04-21 13:34:49-- https://127.0.0.1:8888/
Connecting to 127.0.0.1:8888... connected.
Unable to establish SSL connection.

```

also, i have been checking the docker-compose.yml you said and i rewrite my docker-compose.yml with a new router

```auto
      # Dashboard
      - "traefik.http.routers.cuadro_de_mando.rule=Host(`servidor.ejemplo.com`)"
      - "traefik.http.routers.cuadro_de_mando.service=api@internal"
      - "traefik.http.routers.cuadro_de_mando.middlewares=dashboard_auth"
      - "traefik.http.middlewares.dashboard_auth.basicauth.users=gestor:$$apr1$$cLtMckxk$$ZDXcGECjJ6tl.q17BnIrF." 

```

but i get the same errors

---

<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:** [April 21, 2023, 11:54am UTC](https://community.traefik.io/t/traefik-docker-basic-auth-for-dashboard-doesnt-work-neither-redirection-to-https/18329/4 "2023-04-21T11:54:48Z")

</div>

Your Traefik Dashboard is now listening on the main `entrypoints`, not on port 8888. (You haven't declared that as entrypoint.)

Also you can't access it via IP, because Traefik will only forward when the domain from `rule=Host()` is used. Well, you can use IP, but you need to supply the domain as HTTP header in the `wget`.

---

<div class="post-metadata">

**Author:** ![ginesdelpan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ginesdelpan/32/4991_2.png) [@ginesdelpan](https://community.traefik.io/u/ginesdelpan)\
**Post date:** [April 25, 2023, 8:17am UTC](https://community.traefik.io/t/traefik-docker-basic-auth-for-dashboard-doesnt-work-neither-redirection-to-https/18329/5 "2023-04-25T08:17:06Z")

</div>

@bluepuma77 you were right: i missed the entrypoint for the port 8888

and another reason it didn't work was that i had i mistake 'exposing' the port because i had written:

```auto
- "8888:8080"

```

and it is

```auto
- "8888:8888"

```

so, my full docker-compose.yml is:

```auto
services:
  traefik:
    image: traefik:v2.9.10
    container_name: "traefik"
    restart: always
    command:
      - "--log.level=DEBUG"
      - "--api.dashboard=true"
      - "--entrypoints.web_80.address=:80"
      - "--entrypoints.web_443.address=:443"
      - "--entrypoints.web_cuadro_mando.address=:8888"
      - "--providers.docker=true"
      - "--providers.docker.exposedbydefault=false"
      - "--certificatesresolvers.midesafiotls.acme.httpchallenge=true"
      - "--certificatesresolvers.midesafiotls.acme.httpchallenge.entrypoint=web_80"
      - "--certificatesresolvers.midesafiotls.acme.email=fulano@ejemplo.com"
      - "--certificatesresolvers.midesafiotls.acme.storage=/letsencrypt/acme.json"

    ports: - "80:80"
      - "80:80"
      - "443:443"
      - "8888:8888" # para el dashboard

    labels:
      - "traefik.enable=true"

      # HTTPS Redirect
      - "traefik.http.routers.http-catchall.rule=hostregexp(`{host:.+}`)"
      - "traefik.http.routers.http-catchall.entrypoints=web_80"
      - "traefik.http.routers.http-catchall.middlewares=redirect-to-https"
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"

      # Dashboard: accesible en: https://servidor.ejemplo.com:8888/dashboard/
      - "traefik.http.routers.cuadro_de_mando.entrypoints=web_cuadro_mando"
      - "traefik.http.routers.cuadro_de_mando.rule=Host(`servidor.ejemplo.com`)"
      - "traefik.http.routers.cuadro_de_mando.tls=true"
      - "traefik.http.routers.cuadro_de_mando.tls.certresolver=midesafiotls"
      - "traefik.http.routers.cuadro_de_mando.service=api@internal"

      # autenticacion
      - "traefik.http.routers.cuadro_de_mando.middlewares=dashboardauth"
      - "traefik.http.middlewares.dashboardauth.basicauth.users=gestor:$$apr1$$cLtMckxK$$ZDXcGECjJ6tl.qi7BnIrF."

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./datos_letsencrypt:/letsencrypt
    networks:
      - red_traefik

```

thank you very much for your help
