Quando si usa un server Amazon e si recupera l’IP del server, viene restituito l’IP privato.
Ho quindi creato questo codice per recuperare l’IP pubblico.
<?
if(in_array(substr($_SERVER['SERVER_ADDR'], 0, 3), array('172')))
if(strrpos(gethostname(), '.compute.internal')!==false)
$_SERVER['SERVER_ADDR'] = file_get_contents('http://169.254.169.254/latest/meta-data/public-ipv4');
echo $_SERVER['SERVER_ADDR'];
?>



