# Exposing Traefik dashboard on a different port

**URL:** <https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518>\
**Category:** Traefik v2\
**Tags:** docker, dashboard-api\
**Created:** [November 18, 2022, 10:20pm UTC](https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518 "2022-11-18T22:20:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![msokol](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@msokol](https://community.traefik.io/u/msokol)\
**Post date:** [November 18, 2022, 10:20pm UTC](https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518/1 "2022-11-18T22:20:39Z")

</div>

Was trying to expose traefik dashboard on a non standard port. Here is my docker-compose.yml

```auto
version: "3.9"

services:
  traefik:
    image: traefik:latest
    container_name: traefik
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    networks:
      - proxy
    ports:
      - 2083:2083
      - 8080:8080
      - 443:443
    environment:
      - CF_API_EMAIL={$email}
      - CF_DNS_API_TOKEN={$token}
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - /run/user/1000/docker.sock:/var/run/docker.sock:ro
      - ~/traefik/traefik.yml:/traefik.yml:ro
      - ~/traefik/acme.json:/acme.json
      - ~/traefik/dynamic.yml:/dynamic.yml:ro

    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.entrypoints=dashboard"
      - "traefik.http.routers.traefik.rule=Host(`traefik.example.com`)"
      - "traefik.http.routers.api.entrypoints=dashboard"
      - "traefik.http.routers.traefik.tls=true"
      - "traefik.http.routers.traefik.tls.certresolver=cloudflare"
      - "traefik.http.routers.traefik.tls.domains[0].main=*.example.com"
      - "traefik.http.routers.traefik.tls.domains[0].sans=example.com"
      - "traefik.http.routers.traefik.service=api@internal"

networks:
  proxy:
    external: true
    name: proxy
    driver: bridge
  default:
    driver: bridge

```

traefik.yml has the following lines:

```auto
api:
  dashboard: true
  debug: true

log:
  level: INFO

entryPoints:
  http:
    address: ":80"

  dashboard:
    address: ":2083"

  https:
    address: ":443"

serversTransport:
  insecureSkipVerify: true

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false

  file:
    filename: /dynamic.yml
    watch: true

certificatesResolvers:
  cloudflare:
    acme:
      email: email@example.com
      storage: acme.json
      dnsChallenge:
        provider: cloudflare
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

```

and the last is the content of dynamic.yml:

```auto
# dynamic.yml
http:
  routers:
    dashboard:
      entrypoints:
        - dashboard
      rule: PathPrefix(`/api`) || PathPrefix(`/dashboard`)
      service: api@internal
      middlewares:
        - user-auth

  middlewares:
    https-redirect:
      redirectScheme:
        scheme: https
        permanent: false
        port: 443

    default-headers:
      headers:
        frameDeny: true
        sslRedirect: true
        browserXssFilter: true
        contentTypeNosniff: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsPreload: true
        stsSeconds: 155520011
        referrerPolicy: no-referrer
        featurePolicy: true
        SSLHost: example.com

    user-auth:
      basicAuth:
        users:
          - "user:$pass"

```

Everything works once I switch to a standard 443 port. Once the port is different I obtain "page not found 404". Any help is appreciated. My goal was to forward HTTPS traffic also to another port if it is possible. I run rootless Docker under Fedora Server 37.

---

<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:** [November 18, 2022, 11:01pm UTC](https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518/2 "2022-11-18T23:01:36Z")

</div>

How do you "switch" ports? Just by changing the `entrypoint` to `https`?

> [@msokol](#):
>
> ```auto
> http:
> routers:
> dashboard:
> entrypoints:
> - dashboard
> 
> ```

Maybe its just capitalization (`entryPoints`):

```auto
http:
  routers:
    dashboard:
      entryPoints:
      rule: PathPrefix(`/api`) || PathPrefix(`/dashboard`) || PathPrefix(`/debug`)
      service: api@internal
      middlewares:
        - auth
  middlewares:
    auth:
      basicAuth:
        users:
          - "user:pass"

```

---

<div class="post-metadata">

**Author:** ![msokol](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@msokol](https://community.traefik.io/u/msokol)\
**Post date:** [November 18, 2022, 11:18pm UTC](https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518/3 "2022-11-18T23:18:28Z")

</div>

Yes, using entrypoints as below:

```auto
- "traefik.http.routers.traefik.entrypoints=dashboard"

```

I just noticed that I have access to the dashboard but I have to enter full address `https://traefik.example.com:2083/dashboard/`. With the short link `https://traefik.example.com:2083` I get error 404.

---

<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:** [November 19, 2022, 10:44am UTC](https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518/4 "2022-11-19T10:44:38Z")

</div>

Yes, dashboard is (only) available at `/dashboard/`, as the [docs](https://doc.traefik.io/traefik/operations/dashboard/) state multiple times.

---

<div class="post-metadata">

**Author:** ![msokol](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@msokol](https://community.traefik.io/u/msokol)\
**Post date:** [November 19, 2022, 9:35pm UTC](https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518/5 "2022-11-19T21:35:31Z")

</div>

It seems I figured out where was the source of the problem. I had this line in my config:

```auto
- "traefik.http.routers.traefik.middlewares=auth@file,https-redirect@file"

```

I think `https-redirect` instruction was not able to redirect traffic correctly on "non-https" port (dashboard entry). Moreover, I found it possible to forward any port on the host to "standard" https port 443 on the docker. My main goal was to spin several services with each of them requiring a secure connection on my server. I can consider my problem solved so far. @bluepuma77 thank you for assistance.

---

<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:** [November 22, 2022, 9:36pm UTC](https://community.traefik.io/t/exposing-traefik-dashboard-on-a-different-port/16518/6 "2022-11-22T21:36:12Z")

</div>

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