Get Real User IP Without Installing Cloudflare Apache Module

When using Cloudflare, you will notice that the REMOTE_ADDR variable no longer displays the correct user IP. Since Cloudflare acts as a proxy, the IP will always be a Cloudflare IP. If you have any code such as user votes that are using the IP as a unique way to stop users voting multiple times, you will find that this code is no longer working correctly. The solution to this is to install the Apache module which will correctly resolve the IPs that are being sent from Cloudflare. There is currently no module for Centos 7 and a few other operating systems which leaves us stuck. I looked into the issue and found that there is already a way to access the users IP without installing anything.

If you are using a language like PHP, dump out the server variables using a command such as var_dump($_SERVER); This will allow you to see all of the server variables that you currently have access to. You will see that there are a few new variables that are not normally there. The important variable here is HTTP_CF_CONNECTING_IP. This variable contains the actual user IP that would normally have been present in the REMOTE_ADDR variable. You will also find that the HTTP_X_FORWARDED_FOR variable also contains the exact same value.

This is a quick solution for anyone writing code that is depending on the IP being correct. If you are using any software that you didnt write, you might still be in trouble as this is difficult to change.

Related Articles

Related Questions

Snapchat Keeps Crashing – Anyone Know How to Fix This?

I've been experiencing constant crashes with Snapchat—it shuts down every time I try to open it, usually within about 5 seconds. I've already tried...

How to Keep My GitHub Repository Secure?

I just launched my first major project on GitHub and I'm wondering what security measures I should consider. I want to ensure no one...

Help! Can’t Log Into My Instagram Account

I'm having a major issue trying to get into my Instagram account. I've double-checked my password and the SMS verification code, but I'm constantly...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Latest Tools

Scavenger Hunt Team Randomizer

Planning a scavenger hunt and need to split participants into random teams? Whether you're organizing a school activity, a corporate team-building event, or a...

File Hash Generator Online – Get Instant MD5 and SHA-256 Hashes

Whether you are validating downloads, checking for corruption, or comparing files for duplicates, having a fast and secure way to generate file hashes is...

Visual CSS Editor for Modern Glass UI Effects

Modern UI design is all about clean, layered aesthetics, and few styles deliver this better than glassmorphism. If you're designing sleek user interfaces and...

Fast and Accurate Tap BPM Counter – Free Web Tool

Whether you're producing music, DJing live, or just figuring out the tempo of a song, knowing the BPM (beats per minute) can be critical....

Glassmorphism CSS Generator with Live Preview

Glassmorphism is one of the most visually striking design trends in modern UI. Its soft, frosted-glass effect adds depth and elegance to web interfaces,...

Add Custom Speech and Caption Boxes to Any Image Online

Creating comic-style images used to require complex design tools or specialist software. Whether you're making memes, teaching graphics, social media posts or lighthearted content,...

Latest Posts

Latest Questions