问:127.0.0.1 所有用户上来ip都变成了这个, {"Wl-Proxy-Client-Ip":"127.0.0.1","Proxy-Client-Ip":"127.0.0.1","User-Agent":"Mozilla/5.0 (Linux; Android 5.1.1; oppo a59m Build/LMY49I) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/127.0.0.1 Mobile Safari/537.36 Html5Plus/1.0","Referer":"http://www.wapian.live/user/center/login/?device_id=5cae3e2ff8UYEe9j8uNTCRwLYxOosWLoZBEMnVp1&session=000001&data={“key”:%%22,”passwd”:”15d990bc6da163dea65a2b7d0b16860a”}","Accept-Language":"zh-cn","Accept":"*/*","Connection":"close","X-Forwarded-For":"127.0.0.1, 127.0.0.1","X-Real-Ip":"127.0.0.1","Host":"www.wapian.live","Content-Length":"0","Content-Type":"application/x-www-form-urlencoded"} 用户请求头里有很多ip , 我该取哪一个?,如何获取真实用户真实ip
答:您好,X-Forwarded-For 127.0.0.1 这个值应该是真实IP。
php代码:
<?php
echo "REMOTE_ADDR:".$_SERVER["REMOTE_ADDR"]."</br>";
echo "HTTP_X_FORWARDED_FOR:".$_SERVER["HTTP_X_FORWARDED_FOR"]."</br>";
echo "HTTP_CLIENT_IP:".$_SERVER["HTTP_CLIENT_IP"]."</br>";
echo "HTTP_X_REAL_IP:".$_SERVER["HTTP_X_REAL_IP"]."</br>";
?>
asp代码:
<%
Response.write"REMOTE_ADDR:"&Request.ServerVariables("REMOTE_ADDR") &"</br>"
Response.write"HTTP_X_FORWARDED_FOR:"&Request.ServerVariables("HTTP_X_FORWARDED_FOR")&"</br>"
Response.write"HTTP_CLIENT_IP:"&Request.ServerVariables("HTTP_CLIENT_IP") &"</br>"
Response.write"HTTP_X_REAL_IP:"&Request.ServerVariables("HTTP_X_REAL_IP") &"</br>"
%>
可以在您站点下放下这些获取ip的文件,然后访问,看下那个参数能够获取到您本地的真实IP,非常感谢您长期对我司的支持!