fix some shutdown bugs and so on

This commit is contained in:
2026-07-10 16:04:00 +02:00
parent 01c73819c0
commit 98a4c81701
8 changed files with 98 additions and 4 deletions

View File

@@ -37,7 +37,6 @@ func New(config *Config, client *http.Client) Router {
for _, host := range config.Hosts {
for _, domain := range host.Domains {
curr := Host{host.Port, host.Remotes, host.Secure, &atomic.Uint32{}, make(map[string]*Host), host.AdditionalHeaders}
m[domain] = curr
for subUrl, rewriteHost := range host.Rewrite {
rewrite, ok := m[rewriteHost]
@@ -46,6 +45,7 @@ func New(config *Config, client *http.Client) Router {
}
curr.Rewrites[subUrl] = &rewrite
}
m[domain] = curr
}
}
@@ -82,7 +82,7 @@ func rewriteRequestURL(r *http.Request, host *Host, remote string) error {
r.RequestURI = ""
r.URL.Scheme = remoteUrl.Scheme
r.URL.Host = remoteUrl.Host
r.Header.Set("X-Forwarded-For", r.RemoteAddr)
r.Header.Set("X-Forwarded-For", strings.Split(r.RemoteAddr, ":")[0])
r.Header.Set("Cache-Control", "no-store, no-cache, max-age=0, must-revalidate, proxy-revalidate")
return nil