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

ipAddr sometimes wrong #57

Open
dan335 opened this issue Mar 19, 2015 · 9 comments
Open

ipAddr sometimes wrong #57

dan335 opened this issue Mar 19, 2015 · 9 comments
Labels

Comments

@dan335
Copy link

dan335 commented Mar 19, 2015

ipAddr is correct for about 90% of users. About 10% have it as 127.0.0.1. I have HTTP_FORWARDED_COUNT set to 1. Any idea why it would sometimes be correct and sometimes not?

@mizzao
Copy link
Collaborator

mizzao commented Mar 20, 2015

I'm not sure, but we use the IP address that is provided by Meteor so I'd try and replicate an example where this happens and open an issue with them.

Perhaps the user is behind a corporate proxy and there are multiple X-Forwarded-For headers?

@dan335
Copy link
Author

dan335 commented Mar 20, 2015

connection.httpHeaders shows the x-forwarded-for right? I'll try this and see what happens

Accounts.onLogin(function(info) {
    console.log(info.connection.clientAddress);
    console.log(info.connection.httpHeaders);
})

@dan335
Copy link
Author

dan335 commented Mar 20, 2015

It looks like x-forwarded-for sometimes has two ips seperated by a comma. The first is their ip and the second is 127.0.0.1. When that happens clientAddress is 127.0.0.1 I'll post an issue for it and see what they say.

@dan335 dan335 closed this as completed Mar 20, 2015
@dan335
Copy link
Author

dan335 commented Mar 20, 2015

meteor/meteor#3981

@dan335
Copy link
Author

dan335 commented Mar 26, 2015

What do you think about doing what glasser said in meteor/meteor#3981? Parsing x-forwarded-for and choosing the correct one?

@dan335 dan335 reopened this Mar 26, 2015
@mizzao
Copy link
Collaborator

mizzao commented Mar 26, 2015

I don't know, that seems like something that we should get into Meteor core, not necessarily this package. But we could make a workaround until it is accepted, if you want to try a PR.

I think in some previous user IP packages, someone came up with the correct computation of pulling out IPs from X-Forwarded-For.

@dan335
Copy link
Author

dan335 commented Mar 27, 2015

Here's some info I found about it. http://serverfault.com/a/414166 Sounds like it should go from right to left and pick the first one that's not a trusted ip. Trusted ips I guess could be 192.168.2.1 and 127.0.0.1.

@lorensr
Copy link

lorensr commented May 7, 2015

FYI for anyone getting 127.0.0.1 and no x-forwarded-for, mup ssl may be the cause: meteorhacks/cluster#54

@mizzao
Copy link
Collaborator

mizzao commented May 7, 2015

I guess for trusted IPs the user would have to be able to specify them somehow in the config for this package, possibly with subnet masks (i.e. 192.168.0.0/16, 127.0.0.1, 172.16.0.0/12, 10.0.0.0/8). Seems complicated, anyone want to implement it? :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants