From ddbf4470a15802b22233e32ec33e6678bc15d244 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Wed, 4 Dec 2019 15:28:07 +0100 Subject: [PATCH] fix: debug endpoint when insecure API. --- pkg/provider/traefik/fixtures/full_configuration.json | 8 ++++++++ pkg/provider/traefik/internal.go | 9 +++++++++ pkg/provider/traefik/internal_test.go | 1 + 3 files changed, 18 insertions(+) diff --git a/pkg/provider/traefik/fixtures/full_configuration.json b/pkg/provider/traefik/fixtures/full_configuration.json index 3544aa39c..e8c3a9ec6 100644 --- a/pkg/provider/traefik/fixtures/full_configuration.json +++ b/pkg/provider/traefik/fixtures/full_configuration.json @@ -21,6 +21,14 @@ "rule": "PathPrefix(`/`)", "priority": 2147483645 }, + "debug": { + "entryPoints": [ + "traefik" + ], + "service": "api@internal", + "rule": "PathPrefix(`/debug`)", + "priority": 2147483646 + }, "ping": { "entryPoints": [ "test" diff --git a/pkg/provider/traefik/internal.go b/pkg/provider/traefik/internal.go index 1ee282cee..1501b29a0 100644 --- a/pkg/provider/traefik/internal.go +++ b/pkg/provider/traefik/internal.go @@ -95,6 +95,15 @@ func (i *Provider) apiConfiguration(cfg *dynamic.Configuration) { StripPrefix: &dynamic.StripPrefix{Prefixes: []string{"/dashboard/", "/dashboard"}}, } } + + if i.staticCfg.API.Debug { + cfg.HTTP.Routers["debug"] = &dynamic.Router{ + EntryPoints: []string{"traefik"}, + Service: "api@internal", + Priority: math.MaxInt32 - 1, + Rule: "PathPrefix(`/debug`)", + } + } } cfg.HTTP.Services["api"] = &dynamic.Service{} diff --git a/pkg/provider/traefik/internal_test.go b/pkg/provider/traefik/internal_test.go index 9d1edbc5e..6e43a531f 100644 --- a/pkg/provider/traefik/internal_test.go +++ b/pkg/provider/traefik/internal_test.go @@ -28,6 +28,7 @@ func Test_createConfiguration(t *testing.T) { API: &static.API{ Insecure: true, Dashboard: true, + Debug: true, }, Ping: &ping.Handler{ EntryPoint: "test",