From 66be04f39e433f9007229d97dfa7e0be5087cde9 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Thu, 16 Nov 2017 09:20:03 +0100 Subject: [PATCH 1/8] Documentation archive --- docs/archive.md | 17 +++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 18 insertions(+) create mode 100644 docs/archive.md diff --git a/docs/archive.md b/docs/archive.md new file mode 100644 index 000000000..166815b3d --- /dev/null +++ b/docs/archive.md @@ -0,0 +1,17 @@ +## Previous documentation + +- [Latest stable](https://docs.traefik.io) + +- [Experimental](https://master--traefik-docs.netlify.com/) + +- [v1.4 aka Roquefort](http://v1-4.archive.docs.traefik.io/) + +- [v1.3 aka Raclette](http://v1-3.archive.docs.traefik.io/) + +- [v1.2 aka Morbier](http://v1-2.archive.docs.traefik.io/) + +- [v1.1 aka Camembert](http://v1-1.archive.docs.traefik.io/) + +## More + +[Change log](https://github.com/containous/traefik/blob/master/CHANGELOG.md) \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index cd2a14d8c..96fbad13e 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -95,3 +95,4 @@ pages: - 'Clustering/HA': 'user-guide/cluster.md' - 'gRPC Example': 'user-guide/grpc.md' - Benchmarks: benchmarks.md + - 'Archive': 'archive.md' From 1a4564d9985c8ae19f333c060dbfd67efe34f65d Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Sat, 18 Nov 2017 01:10:03 +0100 Subject: [PATCH 2/8] http.Server log goes to Debug level. --- server/server.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/server.go b/server/server.go index a1c9c63ed..97f980661 100644 --- a/server/server.go +++ b/server/server.go @@ -8,6 +8,7 @@ import ( "errors" "fmt" "io/ioutil" + stdlog "log" "net" "net/http" "net/url" @@ -19,6 +20,7 @@ import ( "sync" "time" + "github.com/Sirupsen/logrus" "github.com/armon/go-proxyproto" "github.com/containous/mux" "github.com/containous/traefik/cluster" @@ -46,7 +48,8 @@ import ( ) var ( - oxyLogger = &OxyLogger{} + oxyLogger = &OxyLogger{} + httpServerLogger = stdlog.New(log.WriterLevel(logrus.DebugLevel), "", 0) ) // Server is the reverse-proxy/load-balancer engine @@ -665,7 +668,7 @@ func (server *Server) prepareServer(entryPointName string, entryPoint *configura SourceCheck: func(addr net.Addr) (bool, error) { ip, ok := addr.(*net.TCPAddr) if !ok { - return false, fmt.Errorf("Type error %v", addr) + return false, fmt.Errorf("type error %v", addr) } return IPs.ContainsIP(ip.IP) }, @@ -679,6 +682,7 @@ func (server *Server) prepareServer(entryPointName string, entryPoint *configura ReadTimeout: readTimeout, WriteTimeout: writeTimeout, IdleTimeout: idleTimeout, + ErrorLog: httpServerLogger, }, listener, nil From 8fe5c220750d05d497610337af08bf9981e3bac9 Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 20 Nov 2017 09:42:02 +0100 Subject: [PATCH 3/8] Exclude RC from doc publication. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 5ca18caaf..53da8682a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,6 +36,7 @@ deploy: on: repo: containous/traefik tags: true + condition: ${TRAVIS_TAG} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ - provider: releases api_key: ${GITHUB_TOKEN} file: dist/traefik* From aae17c817b1f0b53d6cf0d7cf28df8ea9adb92ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20S=C3=A1nchez?= Date: Mon, 20 Nov 2017 11:42:03 +0100 Subject: [PATCH 4/8] Fix issue with label traefik.backend.loadbalancer.stickiness.cookieName --- provider/rancher/rancher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/provider/rancher/rancher.go b/provider/rancher/rancher.go index 341a285cc..7f894b074 100644 --- a/provider/rancher/rancher.go +++ b/provider/rancher/rancher.go @@ -126,7 +126,7 @@ func (p *Provider) hasStickinessLabel(service rancherData) bool { return errStickiness == nil && len(labelStickiness) > 0 && strings.EqualFold(strings.TrimSpace(labelStickiness), "true") } -func (p *Provider) getStickinessCookieName(service rancherData, backendName string) string { +func (p *Provider) getStickinessCookieName(service rancherData) string { if label, err := getServiceLabel(service, types.LabelBackendLoadbalancerStickinessCookieName); err == nil { return label } From 6619a787a32d00711eda2de7ee7e86db69e3a25a Mon Sep 17 00:00:00 2001 From: NicoMen Date: Mon, 20 Nov 2017 15:16:03 +0100 Subject: [PATCH 5/8] Fix problems about duplicated and missing Docker backends/frontends. --- provider/docker/docker.go | 14 ++++++++++---- provider/docker/service_test.go | 24 ++++++++++++------------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/provider/docker/docker.go b/provider/docker/docker.go index cc5598c37..a8b65ea99 100644 --- a/provider/docker/docker.go +++ b/provider/docker/docker.go @@ -302,9 +302,15 @@ func (p *Provider) loadDockerConfig(containersInspected []dockerData) *types.Con frontends := map[string][]dockerData{} backends := map[string]dockerData{} servers := map[string][]dockerData{} + serviceNames := make(map[string]struct{}) for idx, container := range filteredContainers { - frontendName := p.getFrontendName(container, idx) - frontends[frontendName] = append(frontends[frontendName], container) + if _, exists := serviceNames[container.ServiceName]; !exists { + frontendName := p.getFrontendName(container, idx) + frontends[frontendName] = append(frontends[frontendName], container) + if len(container.ServiceName) > 0 { + serviceNames[container.ServiceName] = struct{}{} + } + } backendName := p.getBackend(container) backends[backendName] = container servers[backendName] = append(servers[backendName], container) @@ -427,9 +433,9 @@ func (p *Provider) getServicePriority(container dockerData, serviceName string) // Extract backend from labels for a given service and a given docker container func (p *Provider) getServiceBackend(container dockerData, serviceName string) string { if value, ok := getContainerServiceLabel(container, serviceName, "frontend.backend"); ok { - return value + return container.ServiceName + "-" + value } - return p.getBackend(container) + "-" + provider.Normalize(serviceName) + return strings.TrimPrefix(container.ServiceName, "/") + "-" + p.getBackend(container) + "-" + provider.Normalize(serviceName) } // Extract rule from labels for a given service and a given docker container diff --git a/provider/docker/service_test.go b/provider/docker/service_test.go index 6198921f3..08febf216 100644 --- a/provider/docker/service_test.go +++ b/provider/docker/service_test.go @@ -171,19 +171,19 @@ func TestDockerGetServiceBackend(t *testing.T) { }{ { container: containerJSON(name("foo")), - expected: "foo-myservice", + expected: "foo-foo-myservice", }, { container: containerJSON(labels(map[string]string{ types.LabelBackend: "another-backend", })), - expected: "another-backend-myservice", + expected: "fake-another-backend-myservice", }, { container: containerJSON(labels(map[string]string{ "traefik.myservice.frontend.backend": "custom-backend", })), - expected: "custom-backend", + expected: "fake-custom-backend", }, } @@ -341,8 +341,8 @@ func TestDockerLoadDockerServiceConfig(t *testing.T) { ), }, expectedFrontends: map[string]*types.Frontend{ - "frontend-foo-service": { - Backend: "backend-foo-service", + "frontend-foo-foo-service": { + Backend: "backend-foo-foo-service", PassHostHeader: true, EntryPoints: []string{"http", "https"}, BasicAuth: []string{"test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/", "test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0"}, @@ -354,7 +354,7 @@ func TestDockerLoadDockerServiceConfig(t *testing.T) { }, }, expectedBackends: map[string]*types.Backend{ - "backend-foo-service": { + "backend-foo-foo-service": { Servers: map[string]types.Server{ "service-0": { URL: "http://127.0.0.1:2503", @@ -399,8 +399,8 @@ func TestDockerLoadDockerServiceConfig(t *testing.T) { ), }, expectedFrontends: map[string]*types.Frontend{ - "frontend-foobar": { - Backend: "backend-foobar", + "frontend-test1-foobar": { + Backend: "backend-test1-foobar", PassHostHeader: false, Priority: 5000, EntryPoints: []string{"http", "https", "ws"}, @@ -411,8 +411,8 @@ func TestDockerLoadDockerServiceConfig(t *testing.T) { }, }, }, - "frontend-test2-anotherservice": { - Backend: "backend-test2-anotherservice", + "frontend-test2-test2-anotherservice": { + Backend: "backend-test2-test2-anotherservice", PassHostHeader: true, EntryPoints: []string{}, BasicAuth: []string{}, @@ -424,7 +424,7 @@ func TestDockerLoadDockerServiceConfig(t *testing.T) { }, }, expectedBackends: map[string]*types.Backend{ - "backend-foobar": { + "backend-test1-foobar": { Servers: map[string]types.Server{ "service-0": { URL: "https://127.0.0.1:2503", @@ -433,7 +433,7 @@ func TestDockerLoadDockerServiceConfig(t *testing.T) { }, CircuitBreaker: nil, }, - "backend-test2-anotherservice": { + "backend-test2-test2-anotherservice": { Servers: map[string]types.Server{ "service-0": { URL: "http://127.0.0.1:8079", From c9129b8ecf790cf78b44983ca8f01ce29523a03c Mon Sep 17 00:00:00 2001 From: Ludovic Fernandez Date: Mon, 20 Nov 2017 18:32:03 +0100 Subject: [PATCH 6/8] Remove GzipHandler Fork --- glide.lock | 6 ++---- glide.yaml | 3 --- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/glide.lock b/glide.lock index f9ff37c3a..4a095a11c 100644 --- a/glide.lock +++ b/glide.lock @@ -1,4 +1,4 @@ -hash: bbdbbc9d428937dbaf85e92a3747ebe547f1cc110fbb536c94b5efb3dde6e5ab +hash: de7e6a0069090a5811c003db434da19fe31efcf0c9429d3ccb676295708f0d2b updated: 2017-10-24T14:08:11.364720581+02:00 imports: - name: cloud.google.com/go @@ -383,9 +383,7 @@ imports: repo: https://github.com/ijc25/Gotty.git vcs: git - name: github.com/NYTimes/gziphandler - version: 26a3f68265200656f31940bc15b191f7d10b5bbd - repo: https://github.com/containous/gziphandler.git - vcs: git + version: d6f46609c7629af3a02d791a4666866eed3cbd3e - name: github.com/ogier/pflag version: 45c278ab3607870051a2ea9040bb85fcb8557481 - name: github.com/opencontainers/go-digest diff --git a/glide.yaml b/glide.yaml index 574be7dac..2d458a630 100644 --- a/glide.yaml +++ b/glide.yaml @@ -79,9 +79,6 @@ import: vcs: git - package: github.com/abbot/go-http-auth - package: github.com/NYTimes/gziphandler - version: fork-containous - repo: https://github.com/containous/gziphandler.git - vcs: git - package: github.com/docker/leadership - package: github.com/satori/go.uuid version: ^1.1.0 From 676b79db42b39ba54f63bc8e09e0f63f6edaab82 Mon Sep 17 00:00:00 2001 From: Marco Jantke Date: Tue, 21 Nov 2017 14:28:03 +0100 Subject: [PATCH 7/8] Fix raw path handling in strip prefix --- middlewares/stripPrefix.go | 15 +++++++++++++-- middlewares/stripPrefixRegex.go | 3 +++ middlewares/stripPrefixRegex_test.go | 13 +++++++++++-- middlewares/stripPrefix_test.go | 22 ++++++++++++++++++++-- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/middlewares/stripPrefix.go b/middlewares/stripPrefix.go index 8c1499d63..e156950a1 100644 --- a/middlewares/stripPrefix.go +++ b/middlewares/stripPrefix.go @@ -16,8 +16,11 @@ type StripPrefix struct { func (s *StripPrefix) ServeHTTP(w http.ResponseWriter, r *http.Request) { for _, prefix := range s.Prefixes { - if p := strings.TrimPrefix(r.URL.Path, prefix); len(p) < len(r.URL.Path) { - r.URL.Path = "/" + strings.TrimPrefix(p, "/") + if strings.HasPrefix(r.URL.Path, prefix) { + r.URL.Path = stripPrefix(r.URL.Path, prefix) + if r.URL.RawPath != "" { + r.URL.RawPath = stripPrefix(r.URL.RawPath, prefix) + } s.serveRequest(w, r, strings.TrimSpace(prefix)) return } @@ -35,3 +38,11 @@ func (s *StripPrefix) serveRequest(w http.ResponseWriter, r *http.Request, prefi func (s *StripPrefix) SetHandler(Handler http.Handler) { s.Handler = Handler } + +func stripPrefix(s, prefix string) string { + return ensureLeadingSlash(strings.TrimPrefix(s, prefix)) +} + +func ensureLeadingSlash(str string) string { + return "/" + strings.TrimPrefix(str, "/") +} diff --git a/middlewares/stripPrefixRegex.go b/middlewares/stripPrefixRegex.go index bf2130ca8..bcd66d912 100644 --- a/middlewares/stripPrefixRegex.go +++ b/middlewares/stripPrefixRegex.go @@ -40,6 +40,9 @@ func (s *StripPrefixRegex) ServeHTTP(w http.ResponseWriter, r *http.Request) { } r.URL.Path = r.URL.Path[len(prefix.Path):] + if r.URL.RawPath != "" { + r.URL.RawPath = r.URL.RawPath[len(prefix.Path):] + } r.Header.Add(ForwardedPrefixHeader, prefix.Path) r.RequestURI = r.URL.RequestURI() s.Handler.ServeHTTP(w, r) diff --git a/middlewares/stripPrefixRegex_test.go b/middlewares/stripPrefixRegex_test.go index 038195dac..0f7a10062 100644 --- a/middlewares/stripPrefixRegex_test.go +++ b/middlewares/stripPrefixRegex_test.go @@ -10,13 +10,13 @@ import ( ) func TestStripPrefixRegex(t *testing.T) { - testPrefixRegex := []string{"/a/api/", "/b/{regex}/", "/c/{category}/{id:[0-9]+}/"} tests := []struct { path string expectedStatusCode int expectedPath string + expectedRawPath string expectedHeader string }{ { @@ -61,6 +61,13 @@ func TestStripPrefixRegex(t *testing.T) { path: "/c/api/abc/test4", expectedStatusCode: http.StatusNotFound, }, + { + path: "/a/api/a%2Fb", + expectedStatusCode: http.StatusOK, + expectedPath: "a/b", + expectedRawPath: "a%2Fb", + expectedHeader: "/a/api/", + }, } for _, test := range tests { @@ -68,9 +75,10 @@ func TestStripPrefixRegex(t *testing.T) { t.Run(test.path, func(t *testing.T) { t.Parallel() - var actualPath, actualHeader string + var actualPath, actualRawPath, actualHeader string handlerPath := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { actualPath = r.URL.Path + actualRawPath = r.URL.RawPath actualHeader = r.Header.Get(ForwardedPrefixHeader) }) handler := NewStripPrefixRegex(handlerPath, testPrefixRegex) @@ -82,6 +90,7 @@ func TestStripPrefixRegex(t *testing.T) { assert.Equal(t, test.expectedStatusCode, resp.Code, "Unexpected status code.") assert.Equal(t, test.expectedPath, actualPath, "Unexpected path.") + assert.Equal(t, test.expectedRawPath, actualRawPath, "Unexpected raw path.") assert.Equal(t, test.expectedHeader, actualHeader, "Unexpected '%s' header.", ForwardedPrefixHeader) }) } diff --git a/middlewares/stripPrefix_test.go b/middlewares/stripPrefix_test.go index 2e8778d72..dd3f48106 100644 --- a/middlewares/stripPrefix_test.go +++ b/middlewares/stripPrefix_test.go @@ -16,6 +16,7 @@ func TestStripPrefix(t *testing.T) { path string expectedStatusCode int expectedPath string + expectedRawPath string expectedHeader string }{ { @@ -94,6 +95,15 @@ func TestStripPrefix(t *testing.T) { expectedPath: "/us", expectedHeader: "/stat", }, + { + desc: "raw path is also stripped", + prefixes: []string{"/stat"}, + path: "/stat/a%2Fb", + expectedStatusCode: http.StatusOK, + expectedPath: "/a/b", + expectedRawPath: "/a%2Fb", + expectedHeader: "/stat", + }, } for _, test := range tests { @@ -101,11 +111,12 @@ func TestStripPrefix(t *testing.T) { t.Run(test.desc, func(t *testing.T) { t.Parallel() - var actualPath, actualHeader, requestURI string + var actualPath, actualRawPath, actualHeader, requestURI string handler := &StripPrefix{ Prefixes: test.prefixes, Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { actualPath = r.URL.Path + actualRawPath = r.URL.RawPath actualHeader = r.Header.Get(ForwardedPrefixHeader) requestURI = r.RequestURI }), @@ -118,8 +129,15 @@ func TestStripPrefix(t *testing.T) { assert.Equal(t, test.expectedStatusCode, resp.Code, "Unexpected status code.") assert.Equal(t, test.expectedPath, actualPath, "Unexpected path.") + assert.Equal(t, test.expectedRawPath, actualRawPath, "Unexpected raw path.") assert.Equal(t, test.expectedHeader, actualHeader, "Unexpected '%s' header.", ForwardedPrefixHeader) - assert.Equal(t, test.expectedPath, requestURI, "Unexpected request URI.") + + expectedURI := test.expectedPath + if test.expectedRawPath != "" { + // go HTTP uses the raw path when existent in the RequestURI + expectedURI = test.expectedRawPath + } + assert.Equal(t, expectedURI, requestURI, "Unexpected request URI.") }) } } From 419d46c958604b63844dfd965557eb6ca909a311 Mon Sep 17 00:00:00 2001 From: SALLEYRON Julien Date: Thu, 23 Nov 2017 11:48:03 +0100 Subject: [PATCH 8/8] Prepare release v1.4.4 --- CHANGELOG.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index de70e1906..f421e2a7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ # Change Log +## [v1.4.4](https://github.com/containous/traefik/tree/v1.4.4) (2017-11-21) +[All Commits](https://github.com/containous/traefik/compare/v1.4.3...v1.4.4) + +**Enhancements:** +- **[middleware]** Remove GzipHandler Fork ([#2436](https://github.com/containous/traefik/pull/2436) by [ldez](https://github.com/ldez)) + +**Bug fixes:** +- **[docker]** Fix problems about duplicated and missing Docker backends/frontends. ([#2434](https://github.com/containous/traefik/pull/2434) by [nmengin](https://github.com/nmengin)) +- **[middleware]** Fix raw path handling in strip prefix ([#2382](https://github.com/containous/traefik/pull/2382) by [marco-jantke](https://github.com/marco-jantke)) +- **[rancher]** Fix issue with label traefik.backend.loadbalancer.stickiness.cookieName ([#2423](https://github.com/containous/traefik/pull/2423) by [rawmind0](https://github.com/rawmind0)) +- http.Server log goes to Debug level. ([#2420](https://github.com/containous/traefik/pull/2420) by [ldez](https://github.com/ldez)) + +**Documentation:** +- Documentation archive ([#2405](https://github.com/containous/traefik/pull/2405) by [ldez](https://github.com/ldez)) + ## [v1.4.3](https://github.com/containous/traefik/tree/v1.4.3) (2017-11-14) [All Commits](https://github.com/containous/traefik/compare/v1.4.2...v1.4.3)