Cloudflare visitor ip

Hello, I want to see the ip addresses of users visiting my website via cloudflare. How can I do that?

In Cloudflare support, I was told that the server should also support “CF-Connecting-IP”. is there anything like that?

Welcome!

HTTP_CF_CONNECTING_IP is a custom header sent by Cloudflare to the origin. You can save it to a variable using the global SESSION variable in PHP, like shown below.

You can then save this to a JSON file, a database, or whatever you want to do with it.

$user_ip = $_SERVER["HTTP_CF_CONNECTING_IP"];
6 Likes

Thank you.

1 Like

No problem!

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.