Jump to content

Get User External IP in PHP without using X-Forwarded-For

Hi, I was thinking if there is a way of getting the users IP address without using X-Forwarded-For or any headers? 

The reason for this is the server is behind a loadbalancer that cannot do SSL Termination 

 

HTTP works fine but HTTPS does not but I guess this is because of no SSL Termination capabilities so it cannot add the headers so the server just sees the loadbalancer IP 

 

So is there a way of doing this without changing the loadbalancer? 

Maybe an external service that can do this? 

 

Thanks 

Link to post
Share on other sites

If your load balancer can't insert a header for it due to the SSL Termination thing you mentioned, then I'm not too sure how else it can be done. If possible, you may be able to install your SSL cert on the load balancer, which may then be able to intercept the SSL connection transparently and insert the IP forwarding header for your server.

 

I've never tried any of this before so take this with a grain of salt.

 

Spoiler

 


$_SERVER["REMOTE_ADDR"]

is usually the way to do it, but if you're behind a gateway or another server I'm not too sure how reliable it is.

 

Speedtests

WiFi - 7ms, 22Mb down, 10Mb up

Ethernet - 6ms, 47.5Mb down, 9.7Mb up

 

Rigs

Spoiler

 Type            Desktop

 OS              Windows 10 Pro

 CPU             i5-4430S

 RAM             8GB CORSAIR XMS3 (2x4gb)

 Cooler          LC Power LC-CC-97 65W

 Motherboard     ASUS H81M-PLUS

 GPU             GeForce GTX 1060

 Storage         120GB Sandisk SSD (boot), 750GB Seagate 2.5" (storage), 500GB Seagate 2.5" SSHD (cache)

 

Spoiler

Type            Server

OS              Ubuntu 14.04 LTS

CPU             Core 2 Duo E6320

RAM             2GB Non-ECC

Motherboard     ASUS P5VD2-MX SE

Storage         RAID 1: 250GB WD Blue and Seagate Barracuda

Uses            Webserver, NAS, Mediaserver, Database Server

 

Quotes of Fame

On 8/27/2015 at 10:09 AM, Drixen said:

Linus is light years ahead a lot of other YouTubers, he isn't just an average YouTuber.. he's legitimately, legit.

On 10/11/2015 at 11:36 AM, Geralt said:

When something is worth doing, it's worth overdoing.

On 6/22/2016 at 10:05 AM, trag1c said:

It's completely blown out of proportion. Also if you're the least bit worried about data gathering then you should go live in a cave a 1000Km from the nearest establishment simply because every device and every entity gathers information these days. In the current era privacy is just fallacy and nothing more.

 

Link to post
Share on other sites

Hi burnttoastnice, 

 

Thanks for the reply

$_SERVER["REMOTE_ADDR"] gives me the IP of the gateway which is now what I want 

 

I know if I get another loadbalancer that can do SSL Termination it will work I have tested this 

But due to limitations cannot move over to the new loadbalancer right now 

 

Is there no way of maybe using an external service to give the users external IP? 

 

Thanks 

Link to post
Share on other sites

What a load balance does it reverse proxy like that way

 

Client -> Balancer -> Server #1

 

The client will do a request to Balancer and balancer do a request to server #1 and display it to client. In theory, since server #1 is getting a request from Balancer, it should get the balancer IP. And I'm not sure in practice what it is, it's better that you dump the response headers on balancer and server #1 so we can learn more.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×