I have a website on AWS, recently I decided to run a php function to keep track of where/who is requesting my website. I am getting a persistent request to my homepage from 3 private IP addresses. They are 20 seconds apart, and each one occurs every 30 seconds.
172.31.44.xxx
172.31.8.xxx
172.31.29.xx
How is a private IP requesting my website? I am not able to determine the source of the connection.
I am using this PHP code to get the IP.
if(!empty($_SERVER['HTTP_CLIENT_IP'])){
$ip = $_SERVER['HTTP_CLIENT_IP'];
}elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}else{
$ip = $_SERVER['REMOTE_ADDR'];
}
Is there an error in my code to retrieve the IP properly? Or is there something else going on that I am not aware of. Let me know what you think,
thanks!
EDIT - PHP $_SERVER
response from request
{
"array": {
"USER": "apache",
"HOME": "/usr/share/httpd",
"SCRIPT_NAME": "/index.php",
"REQUEST_URI": "/",
"QUERY_STRING": "",
"REQUEST_METHOD": "GET",
"SERVER_PROTOCOL": "HTTP/1.1",
"GATEWAY_INTERFACE": "CGI/1.1",
"REMOTE_PORT": "29208",
"SCRIPT_FILENAME": "/var/www/html/index.php",
"SERVER_ADMIN": "root@localhost",
"CONTEXT_DOCUMENT_ROOT": "/var/www/html",
"CONTEXT_PREFIX": "",
"REQUEST_SCHEME": "http",
"DOCUMENT_ROOT": "/var/www/html",
"REMOTE_ADDR": "172.31.29.19",
"SERVER_PORT": "80",
"SERVER_ADDR": "172.31.22.151",
"SERVER_NAME": "172.31.22.151",
"SERVER_SOFTWARE": "Apache/2.4.46 ()",
"SERVER_SIGNATURE": "",
"PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin",
"HTTP_ACCEPT_ENCODING": "gzip, compressed",
"HTTP_USER_AGENT": "ELB-HealthChecker/2.0",
"HTTP_CONNECTION": "close",
"HTTP_HOST": "172.31.22.151",
"proxy-nokeepalive": "1",
"UNIQUE_ID": "X@7byXAPCfpNYTyp8Hv5xAAAAAQ",
"FCGI_ROLE": "RESPONDER",
"PHP_SELF": "/index.php",
"REQUEST_TIME_FLOAT": 1609489353.920435,
"REQUEST_TIME": 1609489353
}
}