Skip to content

Commit

Permalink
feat: add X-Forwarded HTTP headers
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominick Brasileiro committed Jun 16, 2023
1 parent 1653904 commit 871ae5d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ var rootCmd = &cobra.Command{
}

reverseProxy := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
req.Header.Set("X-Forwarded-For", req.RemoteAddr)
req.Header.Set("X-Forwarded-Host", req.Header.Get("Host"))
req.Header.Set("X-Forwarded-Port", port)
req.Header.Set("X-Forwarded-Proto", req.Proto)

req.Host = originServerURL.Host
req.URL.Host = originServerURL.Host
req.URL.Scheme = originServerURL.Scheme
Expand Down

0 comments on commit 871ae5d

Please sign in to comment.