only redirect if the request went to the same host
this way requests that are intended for loopback traffic don't get sent
back out
@@ -554,6 +554,7 @@ func (cmd *RunCommand) constructAPIMembers(
logger,
tlsRedirectHandler{
+ matchHostname: cmd.ExternalURL.URL.Hostname(),
externalHost: cmd.ExternalURL.URL.Host,
baseHandler: webHandler,
},
@@ -568,6 +569,7 @@ func (cmd *RunCommand) constructAPIMembers(
apiHandler,
tlsRedirectHandler{
+ matchHostname: cmd.ExternalURL.URL.Hostname(),
externalHost: cmd.ExternalURL.URL.Host,
baseHandler: authHandler,
},
@@ -1290,12 +1292,13 @@ func (cmd *RunCommand) constructAPIHandler(
}
type tlsRedirectHandler struct {
+ matchHostname string
externalHost string
baseHandler http.Handler
}
func (h tlsRedirectHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
- if r.Method == "GET" || r.Method == "HEAD" {
+ if r.URL.Hostname() == h.matchHostname && (r.Method == "GET" || r.Method == "HEAD") {
u := url.URL{
Scheme: "https",
Host: h.externalHost,
