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

x-forwarded-port not being set correctly... maybe #341

Closed
trvsdnn opened this issue Nov 27, 2012 · 4 comments
Closed

x-forwarded-port not being set correctly... maybe #341

trvsdnn opened this issue Nov 27, 2012 · 4 comments

Comments

@trvsdnn
Copy link
Contributor

trvsdnn commented Nov 27, 2012

My understanding is that x-forwarded-port should be set to the server port that the request came in on: 80, 443, etc.

If that's the case, it's not happening. req.connection.remotePort is the requesting client's remote port. I didn't see an obvious way to get the server from the request, but it seems easy enough to determine it from the host header/protocol.

Assuming I'm understanding x-forwarded-port correctly, I've got a branch that fixes the issue here:

https://github.com/blahed/node-http-proxy/compare/x-forwarded-port

@hmalphettes
Copy link

+1
I have used x-forwarded-port with nginx; the expected value of the header is the port of the original request before it was proxied.

Say my node server is running on 3000 and is proxied by node-http-proxy on 3001.
I would like to know when crafting URLs for the original client that the public port is 3001.
At the moment node-http-proxy would give me something like 62112.

I have tested @Blahed's patch and it works for me.

trvsdnn pushed a commit to trvsdnn/node-http-proxy that referenced this issue May 14, 2013
`req.remotePort' returns the ephemeral port, which is not useful.
node v0.10.0 added `req.localPort' which returns what we want, but
we want to maintain backwards compatibility. Fixes http-party#341 & http-party#227
@fideloper
Copy link

Hello!

I'm just coming across this now. I was wondering if there was a planned resolution, or something I missed?

Installing node v0.10.23 and node-http-proxy 0.10.3 shows the same behavior for me.

Edit: The caronte branch exhibits this behavior as well.

yawnt added a commit that referenced this issue Dec 18, 2013
@yawnt
Copy link
Contributor

yawnt commented Dec 18, 2013

@fideloper fixed in 97e4600 :)

@yawnt yawnt closed this as completed Dec 18, 2013
@fideloper
Copy link

Awesome, thanks!

indexzero pushed a commit that referenced this issue Dec 27, 2013
`req.remotePort' returns the ephemeral port, which is not useful.
node v0.10.0 added `req.localPort' which returns what we want, but
we want to maintain backwards compatibility. Fixes #341 & #227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants