Skip to content

Commit

Permalink
[release] v0.10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
azukaar committed Oct 9, 2023
1 parent 3dc4866 commit 93ca8bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.10.1",
"version": "0.10.2",
"description": "",
"main": "test-server.js",
"bugs": {
Expand Down
13 changes: 11 additions & 2 deletions src/proxy/routeTo.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,17 @@ func NewProxy(targetHost string, AcceptInsecureHTTPSTarget bool, VerboseForwardH
}

hostDest := hostname
hostPort := ""
if route.OverwriteHostHeader != "" {
hostDest = route.OverwriteHostHeader
}

// split port
hostDestSplit := strings.Split(hostDest, ":")
if len(hostDestSplit) > 1 {
hostDest = hostDestSplit[0]
hostPort = hostDestSplit[1]
}

// hide hostname (dangerous)
// req.Header.Set("Host", url.Host)
Expand All @@ -104,12 +112,13 @@ func NewProxy(targetHost string, AcceptInsecureHTTPSTarget bool, VerboseForwardH
req.Host = hostDest

if VerboseForwardHeader {
req.Header.Set("X-Origin-Host", hostDest)
req.Header.Set("X-Forwarded-Host", hostDest)
if hostPort != "" {
req.Header.Set("X-Forwarded-Port", hostPort)
}
req.Header.Set("X-Forwarded-For", utils.GetClientIP(req))
req.Header.Set("X-Real-IP", utils.GetClientIP(req))
}

}

if AcceptInsecureHTTPSTarget && url.Scheme == "https" {
Expand Down

0 comments on commit 93ca8bd

Please sign in to comment.