Tor is not an HTTP proxy

I am using Ubuntu 12.04 cloud server as tor proxy server for recycling. The problem I am facing now shows an error

HTTP / 1.0 501 Tor is not an HTTP proxy Content-Type: text / html; encoding = iso-8859-1

$url = 'http://whatismyipaddress.com';
$agent= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.0.3705; .NET CLR 1.1.4322)';

$ch = curl_init('http://whatismyipaddress.com'); 
curl_setopt($ch, CURLOPT_HEADER, 1); 
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); 
curl_setopt($ch, CURLOPT_PROXY, 'https://127.0.01:9050/'); 
curl_exec($ch); 
curl_close($ch);

$result=curl_exec($ch);

Need help, what I'm missing. I'm already trying to use

curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1); 
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);

the request is loaded, and the session ends without result.

+4
source share
1 answer

That's right, Tor is not an HTTP proxy, but a SOCKS v5 proxy.

Based on your cURL option, CURLOPT_HTTPPROXYTUNNELyou tell cURL to try to misuse the Tor proxy (as an HTTP proxy).

- - - - SOCKS:

$proxy = '127.0.0.1:9050';  // no https:// or http://; just host:port
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);

PHP 5.5.23 ( CURLPROXY_SOCKS5_HOSTNAME), curl_setopt($ch, CURLOPT_PROXYTYPE, 7);

cURL- PHP 7.18.0, SOCSK5 , CURLPROXY_SOCKS5 , DNS Tor .

: PHP TorUtils, Tor PHP. TorCurlWrapper, cURL - Tor SOCKS. . composer require dapphp/torutils .

+7

Source: https://habr.com/ru/post/1651251/


All Articles