My server is behind a proxy and I’m trying to get a IP of a user I’m using in PHP
$IP = $_SERVER['HTTP_X_FORWARDED_FOR'];
The problem I see lately some users Ip’s are like this below example Ip’s.
173.0.0.000, 190.000.00.01
173.0.0.000, 190.000.00.02
173.0.0.000, 190.000.00.03
173.0.0.000, 190.000.00.04
173.0.0.000, 190.000.00.05
How would I go about just getting the correct IP like below. It doesn’t happen on all the Ip’s.
The format for
X-Forwarded-Foris: client1, proxy1, proxy2. So you will want to grab the first address in the list:That will grab the first IP address whether there are multiple addresses or just one.