This is my environment setup:

  • Server A hosts the site (Nginx + PHP-FPM + Wordpress)
  • Server B is Nginx reverse proxy for server A
  • Cloudflare reverse proxy is on top of all.

Therefore, user request first go to Cloudflare, then server B and then server A. I've set:

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

on server B. I've also installed Cloudflare wordpress plugin, but Wordpress still gets server B IP address instead of user IP address, detecting Cloudflare IP addresses as originating IPs. :(

Installing Proxy Real IP changes Server B IP addresses to Cloudflare IP addresses, not real user IP.

Any help to get real user IP address at Wordpress end?

1 Answer 1


When multiple proxies are involved and they all support X-Forwarded-For, they each append a value to it. Cloudflare states this in its documentation.

To get this behavior from nginx it looks like you need to set the real_ip_recursive option.

So on the WordPress side the real IP address of the user will usually be the first IP address in the comma separated value list of the X-Forwarded-For header.

Your WordPress header states that it uses "a regular expression" to match the IP address from that field, but it doesn't state that it can deal with multiple values in that field. You may need to update the code of the plugin to work properly when there are multiple values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.