Allow reading Forwarded header as alternative to X-Forwarded- #5861
Replies: 3 comments
-
Just to answer the latter part, you can use any mechanism you need to get the proxy IP, you are not limited to x-forwarded-for only. Just define your own custom |
Beta Was this translation helpful? Give feedback.
-
Thanks for the rapid response! That looks really promising, if I am allowed to overwrite the req.ip and req.secure flags. I couldn't find any reference to which Request properties are in which category (assigned or getters), but I'll see if those work for me.... |
Beta Was this translation helpful? Give feedback.
-
Works an absolute treat 🥳 For anyone else coming here, I overrode request.protocol rather than request.secure. Code works for my use case - I can trust the left-most entry in Forwarded header, and can ignore X-Forwarded headers - but adapt as necessary.
Importantly, for this use case don't enable trust proxy in case any in-between proxies are adding |
Beta Was this translation helpful? Give feedback.
-
A few service providers / proxy servers are beginning to use Forwarded header instead of X-Forwarded-For and related headers. This includes AWS's HTTP API Gateway.
Express does not currently support this header, and I can see no way of hooking up the trust proxy mechanism manually to parse this header, so I am a bit stuffed.
Can you either provide a config setting to use this header for trust proxy, or suggest an alternative way to get this to work?
Beta Was this translation helpful? Give feedback.
All reactions