-
-
Notifications
You must be signed in to change notification settings - Fork 3.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
request.ip via x-forwarded-for should strip out ports #827
Comments
Weird, I have not seen the port being included on Azure before. It's unfortunate that Because ports are split from the host by a colon, it's possible that I could simply add the stripping in |
yeah, i've never seen it before either. i'm using "App Services", if that matters. doing it in ip = url.parse(`http://{ip}`).hostname which seems to strip out the port correctly. let me know if there's a better method |
Unfortunately that
|
So what we can probably do is the following:
That is a rough draft of what to apply to each address entry. What the overhead of that will be I haven't looked into yet. |
Since X-Forwarded-For is not a standard header, wouldn't it be sane to extract |
@fl0w yes! if someone can get started with a module, we can move it to https://github.com/jshttp if it's good |
The |
@dougwilson are you suggesting having https://github.com/jshttp/forwarded as a Koa dependency? Seems a bit overkill compared to current |
@fl0w you asked:
And I was just pointing out there is already a separate repo. Maybe you can elaborate on what you are asking for? |
You already can: Use Object.defineProperty to replace the getter at app.request.ips after you create your app object to whatever function you want to run to get the IPs from any header / parsing method you choose. This is why app.request and app.response exist so you can alter the prototypes. |
@dougwilson I understand now as I went through the lib source. My question came from ignorance. I was pondering about exposing e.g. // pseudo fn-naming
app.registerParserForHeaderField('x-forwarded-for', myCustomParser) It should/would work for all custom headers, not only for x-forwarded-for. But that's something that could be done in user space as you mentioned. Apologies. |
on azure (yes, i know), ports are also being sent as well as the ip in
x-forwarded-for
:request.ip
should not return the port section. aye or nay?The text was updated successfully, but these errors were encountered: