pbojinov / request-ip

A Node.js module for retrieving a request's IP address on the server.
https://npmjs.com/package/request-ip
MIT License
823 stars 102 forks source link

RFC-7239 "Forwarded" header not properly supported #70

Open Waschnick opened 2 years ago

Waschnick commented 2 years ago

Current issue

Proposed solution

Use Case

We are using AWS API Gateway with a private ALB (load balancer) and need the IP to use for getting the geo location. AWS API Gateway uses the Forwarded header for the client ip (see example 2). (And the ALB will set X-Forwarded-For with the private class-c IP from the ALB, but that's another issue)

I would also be open to contribute a PR with tests and the required changes. WDYT?

Sources

pbojinov commented 2 years ago

@Waschnick thank you for posting this and for the detailed example.

I'd be open to accept a PR with tests for this as long as it's backwards compatible with the main function / we can expose a new public function getClientIpFromXForwardedFor

martindeamorin commented 1 year ago

HI @pbojinov, @Waschnick! I created a PR to fix this issue, it would be cool if you could review it! You can fin it here: #71