Traefik Dashboard - custom API path

1/3/2020

Can I change Traefik's default api path for the dashboard from /api to something else? I found this link which is not working anymore, unfortunately.

Traefik is acting as Kubernetes ingress controller in my scenario and I'm using path-based routing. The problem is now that I cannot use /api for my own microservices because the dashboard uses this path already (these endpoints).

Ingress configuration for the dashboard:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: traefik-web-ui
  annotations:
    kubernetes.io/ingress.class: traefik 
    traefik.ingress.kubernetes.io/priority: "2"
spec:
  rules:
  - http:
      paths:
      - path: /dashboard
        backend:
          serviceName: traefik-web-ui
          servicePort: http
      - path: /api <-- needed to make dashboard's api available
        backend:
          serviceName: traefik-web-ui
          servicePort: http 

Ingress configuration for one of the microservices:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: backend
  annotations:
    kubernetes.io/ingress.class: traefik 
    traefik.ingress.kubernetes.io/priority: "999"
spec:
  rules:
  - http:
      paths:
      - path: /apis/ <-- i'd rather use /api here
        backend:
          serviceName: {{ include "my-backend.fullname" . }}
          servicePort: http 
-- Daniel
kubernetes
kubernetes-ingress
traefik
traefik-ingress

1 Answer

1/3/2020

You can customize it as below

defaultEntryPoints = ["http"]

[entryPoints]
  [entryPoints.http]
  address = ":80"

  [entryPoints.foo]
  address = ":8080"

  [entryPoints.bar]
  address = ":8081"

# Activate API and Dashboard
[api]
entryPoint = "bar"
dashboard = true

[file]
  [backends]
    [backends.backend1]
      [backends.backend1.servers.server1]
      url = "http://127.0.0.1:8081"

  [frontends]
    [frontends.frontend1]
    entryPoints = ["foo"]
    backend = "backend1"
      [frontends.frontend1.routes.test_1]
      rule = "PathPrefixStrip:/yourprefix;PathPrefix:/yourprefix"

Corresponding docs from Traefik here

-- Arghya Sadhu
Source: StackOverflow