Meteor-Community-Packages / meteor-user-status

Track user connection state and inactivity in Meteor.
MIT License
559 stars 85 forks source link

How do I get client IP addresses behind a reverse proxy? #48

Open BenAHammond opened 9 years ago

BenAHammond commented 9 years ago

With my Meteor instance behind a reverse proxy (Nginx) the ipAddr is always 127.0.0.1. Any chance you could detect a forwarded port and use that/add it as a new field?

mizzao commented 9 years ago

See #23 and http://docs.meteor.com/#/full/meteor_onconnection. You need to set the HTTP_FORWARDED_COUNT environment variable.

This is also mentioned in the README.

BenAHammond commented 9 years ago

I've got that value set and I'm not seeing the correct IP in the status.lastLogin.upAddr field.

On Wed, Dec 24, 2014 at 9:45 PM, Andrew Mao notifications@github.com wrote:

See #23 https://github.com/mizzao/meteor-user-status/issues/23 and http://docs.meteor.com/#/full/meteor_onconnection.

— Reply to this email directly or view it on GitHub https://github.com/mizzao/meteor-user-status/issues/48#issuecomment-68088470 .

mizzao commented 9 years ago

What do you have that value set to, and how many reverse proxies do you have?

Can you provide an example of the client's full headers from a Meteor.onConnection callback?

This package relies on Meteor's IP address detection, so it's not something that's likely to be an issue with the package.

BenAHammond commented 9 years ago

Okay then, no worries on fixing it. The value is set to 1 at the moment, as I'm only behind a single proxy.

On Fri, Dec 26, 2014 at 1:38 PM, Andrew Mao notifications@github.com wrote:

What do you have that value set to, and how many reverse proxies do you have?

Can you provide an example of the client's full headers from a Meteor.onConnection callback?

This package relies on Meteor's IP address detection, so it's not something that's likely to be an issue with the package.

— Reply to this email directly or view it on GitHub https://github.com/mizzao/meteor-user-status/issues/48#issuecomment-68159253 .

mizzao commented 9 years ago

Try printing out process.env.HTTP_FORWARDED_COUNT when starting your app to see if you've actually set it properly.