The Wayback Machine - https://web.archive.org/web/20230220165208/https://github.com/vapor/vapor/issues/2736
Skip to content
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

Support for peerAddress on Request #2736

Closed
Joannis opened this issue Nov 14, 2021 · 4 comments · Fixed by #2822
Closed

Support for peerAddress on Request #2736

Joannis opened this issue Nov 14, 2021 · 4 comments · Fixed by #2822
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@Joannis
Copy link
Member

Joannis commented Nov 14, 2021

When checking a request's remoteAddress, it's usually the address from which NIO received the request. While that's technically correct, Vapor servers are often hosted behind a reverse-proxy such as nginx. Therefore the original peer's address is often lost. To resolve this, it's not uncommon to set the original peer's address in a header such as X-Forwarded-For.

Describe the solution you'd like
I'd like Vapor to add a property on Request, such as peerAddress, which reads the headers to find the peer's address first.

@Joannis Joannis added the enhancement New feature or request label Nov 14, 2021
@VineFiner
Copy link

vapor/http#32

@Joannis
Copy link
Member Author

Joannis commented Jan 13, 2022

@VineFiner , Vapor/HTTP is only used in Vapor 3. My issue targets regression in Vapor 4.

@0xTim 0xTim added the good first issue Good for newcomers label Jan 13, 2022
@BennyDeBock BennyDeBock added this to To do in Beginner Issues Mar 4, 2022
paunik pushed a commit to paunik/vapor that referenced this issue May 11, 2022
MR for vapor#2736

- Added computed property peerAddress on Request class that parses headers commonly used by proxies and load ballancers to
pass through originating client address
- Added tests for peerAddress computed property
paunik pushed a commit to paunik/vapor that referenced this issue May 11, 2022
MR for vapor#2736

- Added computed property peerAddress on Request class that parses headers commonly used by proxies and load balancers to
pass through originating client address
- Added tests for peerAddress computed property
@paunik
Copy link
Contributor

paunik commented May 11, 2022

Hello @Joannis, I tried to do this for the Vapor 4.
When You have time, could You please check if this is ok?

@Joannis
Copy link
Member Author

Joannis commented May 12, 2022

@paunik I'll continue the discussion in your PR

@0xTim 0xTim linked a pull request May 12, 2022 that will close this issue
paunik pushed a commit to paunik/vapor that referenced this issue May 24, 2022
MR for vapor#2736

- Added computed property peerAddress on Request class that parses headers commonly used by proxies and load balancers to
pass through originating client address
- Added tests for peerAddress computed property
@VaporBot VaporBot moved this from To do to Done in Beginner Issues Jun 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
Development

Successfully merging a pull request may close this issue.

4 participants