From e27e65eb765d73b70b492d6a54f42ace1c750d76 Mon Sep 17 00:00:00 2001 From: SALLEYRON Julien Date: Thu, 30 Nov 2017 16:10:02 +0100 Subject: [PATCH] Fix wrong defaultentrypoint and unexisting entrypoint issue --- cmd/traefik/configuration.go | 2 +- integration/basic_test.go | 38 ++++++++++++++++++++++++++++++++++++ server/server.go | 10 +++++++--- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/cmd/traefik/configuration.go b/cmd/traefik/configuration.go index 1b041d582..692a956c4 100644 --- a/cmd/traefik/configuration.go +++ b/cmd/traefik/configuration.go @@ -279,7 +279,7 @@ func NewTraefikConfiguration() *TraefikConfiguration { LogLevel: "ERROR", EntryPoints: map[string]*configuration.EntryPoint{}, Constraints: types.Constraints{}, - DefaultEntryPoints: []string{}, + DefaultEntryPoints: []string{"http"}, ProvidersThrottleDuration: flaeg.Duration(2 * time.Second), MaxIdleConnsPerHost: 200, IdleTimeout: flaeg.Duration(0), diff --git a/integration/basic_test.go b/integration/basic_test.go index 017205d7c..cc3eacd57 100644 --- a/integration/basic_test.go +++ b/integration/basic_test.go @@ -298,3 +298,41 @@ func (s *SimpleSuite) TestWebCompatibilityWithPath(c *check.C) { err = try.GetRequest("http://127.0.0.1:8000/whoami", 1*time.Second, try.StatusCodeIs(http.StatusOK)) c.Assert(err, checker.IsNil) } + +func (s *SimpleSuite) TestDefaultEntrypointHTTP(c *check.C) { + + s.createComposeProject(c, "base") + s.composeProject.Start(c) + + cmd, output := s.traefikCmd("--entryPoints=Name:http Address::8000", "--debug", "--docker", "--api") + defer output(c) + + err := cmd.Start() + c.Assert(err, checker.IsNil) + defer cmd.Process.Kill() + + err = try.GetRequest("http://127.0.0.1:8080/api/providers", 1*time.Second, try.BodyContains("PathPrefix")) + c.Assert(err, checker.IsNil) + + err = try.GetRequest("http://127.0.0.1:8000/whoami", 1*time.Second, try.StatusCodeIs(http.StatusOK)) + c.Assert(err, checker.IsNil) +} + +func (s *SimpleSuite) TestWithUnexistingEntrypoint(c *check.C) { + + s.createComposeProject(c, "base") + s.composeProject.Start(c) + + cmd, output := s.traefikCmd("--defaultEntryPoints=https,http", "--entryPoints=Name:http Address::8000", "--debug", "--docker", "--api") + defer output(c) + + err := cmd.Start() + c.Assert(err, checker.IsNil) + defer cmd.Process.Kill() + + err = try.GetRequest("http://127.0.0.1:8080/api/providers", 1*time.Second, try.BodyContains("PathPrefix")) + c.Assert(err, checker.IsNil) + + err = try.GetRequest("http://127.0.0.1:8000/whoami", 1*time.Second, try.StatusCodeIs(http.StatusOK)) + c.Assert(err, checker.IsNil) +} diff --git a/server/server.go b/server/server.go index 3bffebc1f..e2255131a 100644 --- a/server/server.go +++ b/server/server.go @@ -910,13 +910,17 @@ func (s *Server) loadConfig(configurations types.Configurations, globalConfigura log.Errorf("Skipping frontend %s...", frontendName) continue frontend } - + var failedEntrypoints int for _, entryPointName := range frontend.EntryPoints { log.Debugf("Wiring frontend %s to entryPoint %s", frontendName, entryPointName) if _, ok := serverEntryPoints[entryPointName]; !ok { log.Errorf("Undefined entrypoint '%s' for frontend %s", entryPointName, frontendName) - log.Errorf("Skipping frontend %s...", frontendName) - continue frontend + failedEntrypoints++ + if failedEntrypoints == len(frontend.EntryPoints) { + log.Errorf("Skipping frontend %s...", frontendName) + continue frontend + } + continue } newServerRoute := &serverRoute{route: serverEntryPoints[entryPointName].httpRouter.GetHandler().NewRoute().Name(frontendName)}