/ PHP

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"])) {
        $ip=$_SERVER["HTTP_CLIENT_IP"];
    } elseif (!empty($_SERVER["HTTP_X_FORWARDED_FOR"])) {
        // to check ip is pass from proxy
        $ip=$_SERVER["HTTP_X_FORWARDED_FOR"];
    } else {
        $ip=$_SERVER["REMOTE_ADDR"];
    }
    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

Linux

Terraform Installation

A quick installation guide for Terraform on Ubuntu 18.04

Bitcoin - Cryptocurrency not just for geeks

Bitcoin

RollerCoin Intro

An introduction to the RollerCoin site and how you can use it to mine your own coins

Magento 2 Blog Posts

Magento 2

Magento 2.4.x Writing to a Log File

How to log to information to a file in different Magento 2.4.x versions