Skip to content

Commit

Permalink
Get The HeaderXForwardedProto (labstack#941)
Browse files Browse the repository at this point in the history
* Get The HeaderXForwardedProto

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto

* add HeaderXForwardedSsl

* Get The HeaderXForwardedSsl
  • Loading branch information
tossp authored and vishr committed Jun 4, 2017
1 parent 68b89ec commit 353a2f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@ func (c *context) Scheme() string {
if c.IsTLS() {
return "https"
}
if scheme := c.request.Header.Get(HeaderXForwardedProto); scheme != "" {
return scheme
}
if ssl := c.request.Header.Get(HeaderXForwardedSsl); ssl == "on" {
return "https"
}
return "http"
}

Expand Down
1 change: 1 addition & 0 deletions echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const (
HeaderXForwardedProto = "X-Forwarded-Proto"
HeaderXHTTPMethodOverride = "X-HTTP-Method-Override"
HeaderXForwardedFor = "X-Forwarded-For"
HeaderXForwardedSsl = "X-Forwarded-Ssl"
HeaderXRealIP = "X-Real-IP"
HeaderXRequestID = "X-Request-ID"
HeaderServer = "Server"
Expand Down

0 comments on commit 353a2f8

Please sign in to comment.