Skip to content

Commit

Permalink
tls: revert unauthenticated access for localhost
Browse files Browse the repository at this point in the history
This is not safe when using tailscale, which proxies traffic to localhost by
default. Thanks to joneskoo@ for the report!
  • Loading branch information
stapelberg committed Mar 20, 2022
1 parent 1c3bb23 commit 6e97c66
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions httpsredirect.go
@@ -1,19 +1,11 @@
package gokrazy

import (
"net"
"net/http"
)

func httpsRedirect(redirectPort string) func(w http.ResponseWriter, r *http.Request) {
return func(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
if redirectPort != "443" {
r.URL.Host += ":" + redirectPort
Expand Down

0 comments on commit 6e97c66

Please sign in to comment.