I have a PHP script sitting on a server that is hit by several different machines at different times throughout the day based on cronjobs that are setup on each machine. I'd like to know the IP of the machines making the request and when it is made by a browser, the following executes successfully:
<?php
...
echo $_SERVER['REMOTE_ADDR'];
...
?>
However, when made by CURL or any other command line tool I have attempted to use (lynx included), I end up with the following garbage:
2701:5:4a80:7d:2ee:8eff:5e61:801d
From the investigation I've done, this is a result of Apache not populating the $_SERVER
variable for requests received that are made from the command line.
REMOTE ADDR Issue with Cron Job
Anyone know of a way to get command line requests to play nice with the $_SERVER
variable or should I go down another route?
That's not garbage, that is the correct remote address. Someone used IPv6 to access your server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With