오길호2023-09-11T11:30:26+09:00使用亚马逊服务器时,显示的服务器IP通常是私有IP。 因此,我创建了这个脚本来获取公共IP地址。 <? 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']; ?>