X-Forwarded-Proto must not skip the redirection.

This commit is contained in:
Ludovic Fernandez 2019-11-15 12:36:04 +01:00 committed by Traefiker Bot
parent 3fd330c2fb
commit 42a8d84a1f
3 changed files with 48 additions and 17 deletions

View file

@ -132,19 +132,13 @@ func rawURL(req *http.Request) string {
uri = match[4]
}
if req.TLS != nil || isXForwardedHTTPS(req) {
if req.TLS != nil {
scheme = "https"
}
return strings.Join([]string{scheme, "://", host, port, uri}, "")
}
func isXForwardedHTTPS(request *http.Request) bool {
xForwardedProto := request.Header.Get("X-Forwarded-Proto")
return len(xForwardedProto) > 0 && xForwardedProto == "https"
}
func applyString(in string, out io.Writer, req *http.Request) error {
t, err := template.New("t").Parse(in)
if err != nil {