run as non root and non host network mode

This commit is contained in:
yusing
2025-01-31 06:32:09 +08:00
parent 357897a0cd
commit b3290e2665
15 changed files with 107 additions and 73 deletions

View File

@@ -22,7 +22,7 @@ func (redirectHTTP) before(w http.ResponseWriter, r *http.Request) (proceed bool
if i := strings.Index(host, ":"); i != -1 {
host = host[:i] // strip port number if present
}
r.URL.Host = host + ":" + common.ProxyHTTPSPort
r.URL.Host = host + common.ProxyHTTPSAddr
logging.Debug().Str("url", r.URL.String()).Msg("redirect to https")
http.Redirect(w, r, r.URL.String(), http.StatusTemporaryRedirect)
return true

View File

@@ -15,7 +15,7 @@ func TestRedirectToHTTPs(t *testing.T) {
})
ExpectNoError(t, err)
ExpectEqual(t, result.ResponseStatus, http.StatusTemporaryRedirect)
ExpectEqual(t, result.ResponseHeaders.Get("Location"), "https://example.com:"+common.ProxyHTTPSPort)
ExpectEqual(t, result.ResponseHeaders.Get("Location"), "https://example.com"+common.ProxyHTTPSAddr)
}
func TestNoRedirect(t *testing.T) {