Previous Article

PHP Function IP if behind a proxy

Next Article

Following from my last post, here is the method to get your IP address if you are behind a proxy.

function getRealIPAddr() {
    // check ip from share internet
    if (!empty($_SERVER["HTTP_CLIENT_IP"])) {
    } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
        // to check ip is pass from proxy
    } else {
    return $ip;

As this method gets more accurate results it is better to use this than the previous function.

Avatar of Clive Walkden

Clive Walkden


Latest Articles

Linux command line tools, installations etc


How to Install NordLayer VPN Client on Ubuntu 20.04 and Connect to a Virtual Network

A simple to follow installation guide for NordLayer VPN

MySQL usage, tweaks and learnings


Mastering MySQL Database Imports on Linux

Learn efficient ways to import MySQL databases on Linux using the mysql command-line client. Explore the --source option and < operator for seamless data migration. Master MySQL imports on Linux with our comprehensive guide.

DevOps principles and tool usage


Mastering SSH Key Conversions for DevOps

A guide to convert SSH keys from one version to another using Linux CLI