As a follow-up, X-Forwarded-For *might* be a list of IP addresses if the user is connecting through other proxies. As a result, you should consider that the most useful IP address will probably be the last ip address in the list which is not a local (i.e. 10.* or 192.*) IP address. There are articles on the internet which will give you more information about this.
On Mon, Mar 19, 2012 at 11:25 AM, Angelo Chen <[email protected]>wrote: > Thanks, it works! > > On Mar 19, 10:51 pm, Chris Rhoden <[email protected]> wrote: > > You want to look at X-Forwarded-For > > > > On Mon, Mar 19, 2012 at 10:40 AM, Angelo Chen <[email protected] > >wrote: > > > > > > > > > > > > > > > > > > > > > Hi, > > > my nodejs server runs behind nginx, i have setup to forward ip and > > > host, but following always return 127.0.0.1, why? > > > > > req.connection.remoteAddress > > > > > nginx.conf: > > > > > server { > > > listen 80; > > > server_name samples.com > > > > > root /usr/share/nginx/html; > > > > > location / { > > > proxy_set_header X-Real-IP $remote_addr; > > > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; > > > proxy_set_header Host $http_host; > > > proxy_set_header X-NginX-Proxy true; > > > proxy_pass http://127.0.0.1:3000; > > > proxy_redirect off; > > > } > > > > > -- > > > Job Board:http://jobs.nodejs.org/ > > > Posting guidelines: > > >https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > > > You received this message because you are subscribed to the Google > > > Groups "nodejs" group. > > > To post to this group, send email to [email protected] > > > To unsubscribe from this group, send email to > > > [email protected] > > > For more options, visit this group at > > >http://groups.google.com/group/nodejs?hl=en?hl=en > > > > -- > > chrisrhoden > > -- > Job Board: http://jobs.nodejs.org/ > Posting guidelines: > https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines > You received this message because you are subscribed to the Google > Groups "nodejs" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://groups.google.com/group/nodejs?hl=en?hl=en > -- chrisrhoden -- Job Board: http://jobs.nodejs.org/ Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines You received this message because you are subscribed to the Google Groups "nodejs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nodejs?hl=en?hl=en
