Don't redirect requests from localhost to HTTPS (#78)
This commit is contained in:
parent
5fc5d0ab5d
commit
97987794f9
@ -1,9 +1,18 @@
|
||||
package gokrazy
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"net"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// TODO: Configurable https-port
|
||||
func httpsRedirect(w http.ResponseWriter, r *http.Request) {
|
||||
host, _, _ := net.SplitHostPort(r.RemoteAddr)
|
||||
ip := net.ParseIP(host)
|
||||
if ip.IsLoopback() {
|
||||
http.DefaultServeMux.ServeHTTP(w, r)
|
||||
return
|
||||
}
|
||||
|
||||
r.URL.Host = r.Host
|
||||
r.URL.Scheme = "https"
|
||||
http.Redirect(w, r, r.URL.String(), http.StatusFound) // Redirect to https
|
||||
|
Loading…
x
Reference in New Issue
Block a user