The nginx proxy mode, the client to obtain real IP

Recommended for you: Get network issues from WhatsUp Gold. Not end users.

Recent blog recommendation, found a small problem, using $_SERVER['REMOTE_ADDR']; is the address of the server, search, found the problem, change$_SERVER['HTTP_X_REAL_IP'];:

nginx Proxy mode, the client to obtain real IP

Set in nginx:

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Backend users can access from the Server variables HTTP_X_REAL_IP and HTTP_X_FORWARDED_FOR address in IP.

HTTP_X_REAL_IP value nginx user REMOTE_ADDR

Reference address

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Oscar at January 18, 2014 - 11:28 AM