I have used the below code from link to detect the browser is TOR or not.
But when the server is hosted on AWS, we didn't get the exact $_SERVER['SERVER_ADDR'] as the AWS is providing the private ip of machine or load balancer ips.
So is there any way to detect the AWS private ips from the TOR exit list to detect whether the user is using the TOR browser or not.
In this code, gethostbyname($user_ip.".".$_SERVER['SERVER_PORT'].".".$_SERVER['SERVER_ADDR'].".ip-port.exitlist.torproject.org")=="127.0.0.2" , I did the $_SERVER['SERVER_ADDR'] to static public ip of AWS server and $user_ip to $_SERVER['HTTP_X_FORWARDED_FOR '] and code worked, but if I put actual private IP in the $_SERVER['SERVER_ADDR'] variable provided by AWS, code is not working.