Why Tor cant access localhost pages

99封情书 提交于 2019-12-03 11:45:45

It is the way protocol is designed. When you send a request, it is transported to another machine on Internet with Socks5 envelope. So actual request is made from external server, thus accessing 127.0.0.1 is not possible.

You can use Tor proxy with php in localhost. Using cURL. Put your local IP on LAN proxy config "No proxy for:". Exammple 192.168.1.10. Then call your php as "http://192.168.1.10/your_script.php"

$proxy = '127.0.0.1:9150';
$ur = "http://anydomain.com";
$ch = curl_init();

curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYTYPE, 7);

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    curl_setopt($ch, CURLOPT_URL, $ur);

    $curl_scraped_page = curl_exec($ch);
    $error = curl_error($ch);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!