culr代理ip的实现,坐等神人!【急】
打印$_server['remote_addr'];获取到真实ip
$_server['http_x_forwarded_for'];获取到代理ip
实现用代理访问网址返回网页内容
$ip = rand(1,255).'.'.rand(1,255).'.'.rand(1,255).'.'.rand(1,255);
$headerarr[] = 'x-forwarded-for' .':' . $ip;
$ch = curl_init();
curl_setopt ($ch, curlopt_url, http://ip138.com);
curl_setopt ($ch, curlopt_httpheader , $headerarr );
$re=curl_exec($ch);
var_dump($re);
这是我写的代码,没什么用。
$_server['remote_addr'];打印出我真实的ip
$_server['http_x_forwarded_for'];打印出来的是我虚拟的ip
能让程序返回内容中的ip显示为代理ip即可
php curl ip代理 分享到: 更多
------解决方案--------------------
curl_setopt($ch, curlopt_httpproxytunnel, true);
curl_setopt($ch, curlopt_proxy, $proxy);
------解决方案--------------------
//第一、伪造来源http_referer
$ch = curl_init(); //初始化
curl_setopt($ch, curlopt_url, http://www.example.com/); //你要访问的页面
curl_setopt($ch, curlopt_referer, http://www.example.com/); //伪造来源http_referer
curl_setopt($chtml,curlopt_returntransfer,1); //是否显示内容
curl_exec($ch); //执行
curl_close($ch); //返回关闭
//第二、用代理
curl_setopt($ch,curlopt_proxy,http://www.domain.com);
//第三、伪造ip
curl_setopt($ch, curlopt_httpheader, array('x-forwarded-for:8.8.8.8', 'client-ip:8.8.8.8')); //构造ip
------解决方案--------------------
也接近纯白了
remote_addr 是访问网站的那台机器的ip 假设为p
http_x_forwarded_for 是p向网站发出的ip信息,用remote_addr获得向p发出请求的机器的ip
如果你的本机为p,可以伪造http_x_forwarded_for,但不能伪造remote_addr
如果你是通过代理p访问网站,则网站收到remote_addr为p的ip,但http_x_forwarded_for你则无法伪造,因为是p发出的,不受你控制
------解决方案--------------------
$_server['remote_addr'] 来源的ip,如果是经代理访问的,就是代理的ip
$_server['http_x_forwarded_for'] 访问代理的机器的ip
------解决方案--------------------
引用:我是想$_server['remote_addr']打印出来的ip是我设置的代理的ip,能实现吗?求方法
见#1 或 #2,设置 curlopt_proxy