-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add middleware with support proxy headers #2453
base: master
Are you sure you want to change the base?
Conversation
} | ||
|
||
if c.Request().Header.Get(echo.HeaderXForwardedHost) != "" { | ||
c.Request().Host = c.Request().Header.Get(echo.HeaderXForwardedHost) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting host from proxied request is little bit more complex and has security nuances. Please see https://github.com/labstack/echo/blob/master/ip.go
NB: it is missing tests |
@padremortius Do you want to continue on this PR or shall we close it? |
Add unit-test for getScheme
@lammel, yes. Added some changes and unit-test |
unit tests are only for scheme parsing. this is only small part of that middleware. Currently it introduces new header "forwarded" RFC7239 which I think - if implemented should be integrated into about RFC7239 and Go standard library golang/go#30963 maybe instead of that Regex we could have small parser that takes in header value, goes over that rune/char by rune/char and outputs parsed parts or an error. RFC7239 should not be that complex as spec is not that complex. |
Add middleware for support proxy headers (based on code gorilla mux handler https://github.com/gorilla/handlers/blob/master/proxy_headers.go)