From f537ecf2328c2486f12a4cc42a5d3c768cbca4f4 Mon Sep 17 00:00:00 2001 From: Aaron Bieber Date: Fri, 28 Jun 2024 07:50:11 -0600 Subject: [PATCH] allow host-header to be set manually --- main.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 55383d9..3e44439 100644 --- a/main.go +++ b/main.go @@ -31,6 +31,7 @@ func main() { sName := flag.String("name", "", "server name we will be reverse proxying for") cIP := flag.String("ip", "127.0.0.1", "ip address to reverse proxy to") cPort := flag.Int("port", 5000, "port to reverse proxy to") + cHost := flag.String("host-header", "", "manually set the Host header to this value") prof := flag.Bool("prof", false, fmt.Sprintf("expose pprof on port %d", *cPort+1)) flag.Parse() @@ -63,7 +64,11 @@ func main() { req.Header.Add("X-Forwarded-Host", req.Host) req.Header.Add("X-Origin-Host", rpURL.Host) req.URL.Scheme = rpURL.Scheme - req.URL.Host = rpURL.Host + if *cHost != "" { + req.URL.Host = *cHost + } else { + req.URL.Host = rpURL.Host + } httpLog(req) }}