Skip to content

Commit

Permalink
Support non-root prefixed reverse proxy environments (#45)
Browse files Browse the repository at this point in the history
* support X-Forwarded-Prefix for reverse proxied prefix stripping environments

* sign cla

---------

Co-authored-by: Nick Gregory <nick.gregory@openenterprise.co.uk>
Co-authored-by: Paul Greenberg <greenpau@users.noreply.github.com>
  • Loading branch information
3 people committed Sep 4, 2023
1 parent 20ba1ef commit 5b7a408
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assets/cla/consent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@
email: sergiucozma1994@gmail.com
- name: Riccardo Piola
email: riccardopiola@live.it
- name: Nick Gregory
email: ng-cla@openenterprise.co.uk
4 changes: 4 additions & 0 deletions pkg/util/addr/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ func GetCurrentURLWithSuffix(r *http.Request, suffix string) (string, error) {
u += ":" + port
}
}

prefix := r.Header.Get("X-Forwarded-Prefix")
u += prefix

if suffix != "" {
i := strings.Index(r.RequestURI, suffix)
if i < 0 {
Expand Down
2 changes: 2 additions & 0 deletions pkg/util/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ func GetCurrentBaseURL(r *http.Request) string {
redirectBaseURL += ":" + redirPort
}
}
redirPrefix := r.Header.Get("X-Forwarded-Prefix")
redirectBaseURL += redirPrefix

return redirectBaseURL
}
Expand Down

0 comments on commit 5b7a408

Please sign in to comment.