Merge branch v2.2 into v2.3
This commit is contained in:
commit
675655d437
5 changed files with 87 additions and 3 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
@ -1,3 +1,13 @@
|
||||||
|
## [v2.2.8](https://github.com/containous/traefik/tree/v2.2.8) (2020-07-28)
|
||||||
|
[All Commits](https://github.com/containous/traefik/compare/v2.2.7...v2.2.8)
|
||||||
|
|
||||||
|
**Bug fixes:**
|
||||||
|
- **[webui]** fix: clean X-Forwarded-Prefix header for the dashboard. ([#7109](https://github.com/containous/traefik/pull/7109) by [ldez](https://github.com/ldez))
|
||||||
|
|
||||||
|
**Documentation:**
|
||||||
|
- **[docker]** spelling(docs/content/routing/providers/docker.md) ([#7101](https://github.com/containous/traefik/pull/7101) by [szczot3k](https://github.com/szczot3k))
|
||||||
|
- **[k8s]** doc: add name of used key for kubernetes client auth ([#7068](https://github.com/containous/traefik/pull/7068) by [smueller18](https://github.com/smueller18))
|
||||||
|
|
||||||
## [v2.2.7](https://github.com/containous/traefik/tree/v2.2.7) (2020-07-20)
|
## [v2.2.7](https://github.com/containous/traefik/tree/v2.2.7) (2020-07-20)
|
||||||
[All Commits](https://github.com/containous/traefik/compare/v2.2.6...v2.2.7)
|
[All Commits](https://github.com/containous/traefik/compare/v2.2.6...v2.2.7)
|
||||||
|
|
||||||
|
|
|
@ -428,6 +428,7 @@ metadata:
|
||||||
|
|
||||||
spec:
|
spec:
|
||||||
clientAuth:
|
clientAuth:
|
||||||
|
# the CA certificate is extracted from key `tls.ca` of the given secrets.
|
||||||
secretNames:
|
secretNames:
|
||||||
- secretCA
|
- secretCA
|
||||||
clientAuthType: RequireAndVerifyClientCert
|
clientAuthType: RequireAndVerifyClientCert
|
||||||
|
|
|
@ -535,7 +535,7 @@ You can declare UDP Routers and/or Services using labels.
|
||||||
my-container:
|
my-container:
|
||||||
# ...
|
# ...
|
||||||
labels:
|
labels:
|
||||||
- "traefik.udp.routers.my-router.entrypoint=udp"
|
- "traefik.udp.routers.my-router.entrypoints=udp"
|
||||||
- "traefik.udp.services.my-service.loadbalancer.server.port=4123"
|
- "traefik.udp.services.my-service.loadbalancer.server.port=4123"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
|
||||||
"github.com/containous/traefik/v2/pkg/log"
|
"github.com/containous/traefik/v2/pkg/log"
|
||||||
assetfs "github.com/elazarl/go-bindata-assetfs"
|
assetfs "github.com/elazarl/go-bindata-assetfs"
|
||||||
|
@ -23,11 +24,29 @@ func (g DashboardHandler) Append(router *mux.Router) {
|
||||||
// Expose dashboard
|
// Expose dashboard
|
||||||
router.Methods(http.MethodGet).
|
router.Methods(http.MethodGet).
|
||||||
Path("/").
|
Path("/").
|
||||||
HandlerFunc(func(response http.ResponseWriter, request *http.Request) {
|
HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
|
||||||
http.Redirect(response, request, request.Header.Get("X-Forwarded-Prefix")+"/dashboard/", http.StatusFound)
|
http.Redirect(resp, req, safePrefix(req)+"/dashboard/", http.StatusFound)
|
||||||
})
|
})
|
||||||
|
|
||||||
router.Methods(http.MethodGet).
|
router.Methods(http.MethodGet).
|
||||||
PathPrefix("/dashboard/").
|
PathPrefix("/dashboard/").
|
||||||
Handler(http.StripPrefix("/dashboard/", http.FileServer(g.Assets)))
|
Handler(http.StripPrefix("/dashboard/", http.FileServer(g.Assets)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func safePrefix(req *http.Request) string {
|
||||||
|
prefix := req.Header.Get("X-Forwarded-Prefix")
|
||||||
|
if prefix == "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
parse, err := url.Parse(prefix)
|
||||||
|
if err != nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
if parse.Host != "" {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return parse.Path
|
||||||
|
}
|
||||||
|
|
54
pkg/api/dashboard_test.go
Normal file
54
pkg/api/dashboard_test.go
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_safePrefix(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
desc string
|
||||||
|
value string
|
||||||
|
expected string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
desc: "host",
|
||||||
|
value: "https://example.com",
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "host with path",
|
||||||
|
value: "https://example.com/foo/bar?test",
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "path",
|
||||||
|
value: "/foo/bar",
|
||||||
|
expected: "/foo/bar",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "path without leading slash",
|
||||||
|
value: "foo/bar",
|
||||||
|
expected: "foo/bar",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range testCases {
|
||||||
|
test := test
|
||||||
|
t.Run(test.desc, func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
req, err := http.NewRequest(http.MethodGet, "http://localhost", nil)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
req.Header.Set("X-Forwarded-Prefix", test.value)
|
||||||
|
|
||||||
|
prefix := safePrefix(req)
|
||||||
|
|
||||||
|
assert.Equal(t, test.expected, prefix)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue