diff --git a/server/server.go b/server/server.go index 5b8b2a297..e4631adf1 100644 --- a/server/server.go +++ b/server/server.go @@ -952,7 +952,7 @@ func (s *Server) loadConfig(configurations types.Configurations, globalConfigura entryPoint := globalConfiguration.EntryPoints[entryPointName] n := negroni.New() - if entryPoint.Redirect != nil { + if entryPoint.Redirect != nil && entryPointName != entryPoint.Redirect.EntryPoint { if redirectHandlers[entryPointName] != nil { n.Use(redirectHandlers[entryPointName]) } else if handler, err := s.buildRedirectHandler(entryPointName, entryPoint.Redirect); err != nil { @@ -1141,7 +1141,7 @@ func (s *Server) loadConfig(configurations types.Configurations, globalConfigura log.Infof("Configured IP Whitelists: %s", frontend.WhitelistSourceRange) } - if frontend.Redirect != nil { + if frontend.Redirect != nil && entryPointName != frontend.Redirect.EntryPoint { rewrite, err := s.buildRedirectHandler(entryPointName, frontend.Redirect) if err != nil { log.Errorf("Error creating Frontend Redirect: %v", err) @@ -1347,7 +1347,7 @@ func (s *Server) buildRedirect(entryPointName string) (string, string, error) { protocol = "https" } - replacement := protocol + "://$1" + match[0] + "$2" + replacement := protocol + "://${1}" + match[0] + "${2}" return defaultRedirectRegex, replacement, nil } diff --git a/server/server_test.go b/server/server_test.go index 72a0e5f42..0a9f7228e 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -1071,7 +1071,7 @@ func TestServerBuildRedirect(t *testing.T) { "https": &configuration.EntryPoint{Address: ":443", TLS: &tls.TLS{}}, }, }, - expectedReplacement: "https://$1:443$2", + expectedReplacement: "https://${1}:443${2}", }, { desc: "Redirect endpoint http to http02 with HTTP protocol", @@ -1082,7 +1082,7 @@ func TestServerBuildRedirect(t *testing.T) { "http02": &configuration.EntryPoint{Address: ":88"}, }, }, - expectedReplacement: "http://$1:88$2", + expectedReplacement: "http://${1}:88${2}", }, { desc: "Redirect endpoint to non-existent entry point",