How to get the actual IP address of the Cloud Flare proxy server that is being replaced by nginx with user's IP address

422 views Asked by At

My visitors IP address is being fed into my php application and replaced by the actual HTTP Header between the server and cloudflare using these nginx configuration:

set_real_ip_from 103.31.4.0/22;
set_real_ip_from 141.101.64.0/18; 
//....
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2405:8100::/32;

real_ip_header CF-Connecting-IP;

And I can now access it via php's $_SERVER['REMOTE_ADDR'], however in my application I am in need of getting the cloudflare IP address. What can I add here so it passes the IP as another variable accessible via $_SERVER.

I am having issues with Laravel Jetstreams built in URL signature verifications, and none of the plugins for TrustProxies middleware that handles cloudflare seems to work. I am trying to see the IP address of the cloudflare node to make sure it exists in my list of IP CIDR but can't figure out how to do that.

0

There are 0 answers