# Dashboard and API only work when api.insecure is true

**URL:** <https://community.traefik.io/t/dashboard-and-api-only-work-when-api-insecure-is-true/1582>\
**Category:** Traefik v2\
**Tags:** dashboard-api\
**Created:** [September 13, 2019, 6:22pm UTC](https://community.traefik.io/t/dashboard-and-api-only-work-when-api-insecure-is-true/1582 "2019-09-13T18:22:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deweller](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/deweller/32/673_2.png) [@deweller](https://community.traefik.io/u/deweller)\
**Post date:** [September 13, 2019, 6:22pm UTC](https://community.traefik.io/t/dashboard-and-api-only-work-when-api-insecure-is-true/1582/1 "2019-09-13T18:22:32Z")

</div>

My config is below. It only works when the insecure line is uncommented.

[http://10.195.133.68:8000](http://10.195.133.68:8000) returns a 404. When I uncomment the `insecure = true` line, I am able to access the dashboard.

```auto
[global]
  checkNewVersion = true
  sendAnonymousUsage = true

# Default:
[entryPoints]
  [entryPoints.web]
    address = ":80"

  [entryPoints.https]
    address = ":443"

  [entryPoints.traefik]
    address = ":8000"

[http.routers.my-api]
    entryPoints = ["traefik"]
    rule="Host(`10.195.133.68`)"
    service="api@internal"
    middlewares=["auth"]

[http.middlewares.auth.basicAuth]
    users = [
        "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", 
      ]

[api]
  # insecure = true
  dashboard = true
[ping]
[providers.docker]

```

---

<div class="post-metadata">

**Author:** ![ldez](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/ldez/32/5_2.png) [@ldez](https://community.traefik.io/u/ldez)\
**Post date:** [September 13, 2019, 9:19pm UTC](https://community.traefik.io/t/dashboard-and-api-only-work-when-api-insecure-is-true/1582/2 "2019-09-13T21:19:04Z")

</div>

- In the v2 the [static configuration](https://docs.traefik.io/v2.0/getting-started/configuration-overview/#the-static-configuration) and the [dynamic configuration](https://docs.traefik.io/v2.0/getting-started/configuration-overview/#the-dynamic-configuration) cannot be mixed by default: you have to create 2 files.
- to use the `file` provider you have to enable the provider.

```auto
## traefik.toml
## Static configuration
[entryPoints]
  [entryPoints.web]
    address = ":80"

  [entryPoints.https]
    address = ":443"

  [entryPoints.traefik]
    address = ":8000"

[api]
  
[ping]

[providers.docker]

[providers.file]
  filename = "dynamic_conf.toml"

```

```auto
## dynamic_conf.toml
## Dynamic configuration

[http.routers.my-api]
    entryPoints = ["traefik"]
    rule = "PathPrefix(`/dashboard`) || PathPrefix(`/api`)"
    service = "api@internal"
    middlewares = ["auth"]

[http.middlewares.auth.basicAuth]
  users = [
    test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", 
  ]

```

---

<div class="post-metadata">

**Author:** ![deweller](https://sea2.discourse-cdn.com/flex020/user_avatar/community.traefik.io/deweller/32/673_2.png) [@deweller](https://community.traefik.io/u/deweller)\
**Post date:** [September 16, 2019, 1:58pm UTC](https://community.traefik.io/t/dashboard-and-api-only-work-when-api-insecure-is-true/1582/3 "2019-09-16T13:58:00Z")

</div>

Separating the dynamic configuration into a separate dynamic file fixed this for me. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![thisismydesign](https://avatars.discourse-cdn.com/v4/letter/t/ed655f/32.png) [@thisismydesign](https://community.traefik.io/u/thisismydesign)\
**Post date:** [April 13, 2020, 10:00am UTC](https://community.traefik.io/t/dashboard-and-api-only-work-when-api-insecure-is-true/1582/4 "2020-04-13T10:00:44Z")

</div>

Following the `docker-compose` example in getting started:

Static config:  
`traefik.toml`

```auto
[api]
[entryPoints.traefik]
  address = ":8080"

```

`docker-compose.yml`

```auto
  reverse-proxy:
    image: traefik:v2.2
    ports:
      # The HTTP port
      - "80:80"
      # The Web UI
      - "8080:8080"
    volumes:
      # So that Traefik can listen to the Docker events
      - /var/run/docker.sock:/var/run/docker.sock
      # Make config present in the container
      - ./traefik.toml:/etc/traefik/traefik.toml
    labels:
      - "traefik.enable=true"
      - "traefik.http.routers.traefik.rule=PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
      - "traefik.http.routers.traefik.entrypoints=traefik"
      - "traefik.http.routers.traefik.service=api@internal"

```
