问题描述
有没有人试过使用旋转代理?这是多么容易实现?它工作得很好吗?您的体验请
PS:我看到的问题如收集很多minuses。
------ UPDATED 04 March 2017 --- ----
我在那里,发现最好的解决方案是:
如果你没有专用的服务器,或者至少有一个vps和一点点耐心不要打扰阅读其余的帖子...
1 - 从源代码安装Squid 3.2(检查下面的注释)
2 - 添加一个20个左右的ip到squid.conf费用约为25 $ month)
3 - 使用新功能来旋转输出ip。
这样,你不需要在你的php脚本上旋转ip的列表,而是连接到同一个ip(例如:192.168.1.1 :3129),但根据随机设置,可见的外发ip ( tcp_outgoing_address
)会轮流显示每个请求。
您需要使用' - enable-http-violations'
编译squid 3.2,以使其成为精英匿名代理。
逐步安装:
yum -y groupinstall'开发工具'
yum -y install openssl-devel
mkdir / meus
cd / meus
wget http://www.squid-cache.org /Versions/v3/3.2/squid-3.2.13.tar.gz
tar -xvf squid-3.2.13.tar.gz
cd squid-3.2.13
./configure - 前缀= / squid32'--enable-remove-policies = heap,lru''--enable-ssl''--with-openssl''--enable-linux-netfilter''--with-pthreads' enable-ntlm-auth-helpers = SMB,fakeauth''--enable-external-acl-helpers = ip_user,ldap_group,unix_group,wbinfo_group''--enable-auth-basic''--enable-auth-digest --enable-auth-negotiate''--enable-auth-ntlm''--with-winbind-auth-challenge''--enable-useragent-log''--enable-referer-log''--disable --enable-cache-digests''--enable-ident-lookups'--enable-cache-digest'' - '--enable-follow-x-forwarding-for''--enable-wccpv2''--enable-fd-config''--with-maxfd = 16384''-enable-http-violations'
make
make install
示例squid.conf(位于本例中/ squid32 /etc/squid.conf):
#this将是squid将运行的ip和端口
http_port 5.5.5.5:33333#更改这个ip和端口...
#squid.conf中的#Extra参数来创建一个精英代理
request_header_access允许allow all
request_header_access授权允许所有
request_header_access WWW认证允许所有
request_header_access代理授权允许所有
request_header_access代理身份验证允许所有
request_header_access高速缓存控制允许所有
request_header_access内容编码允许所有
request_header_access内容长度允许所有
request_header_access内容类型允许所有
request_header_access日期允许所有
request_header_access过期允许所有
request_header_access主机允许all
request_header_access If-Modified-Since允许所有
request_header_access上次修改允许所有
request_header_access位置允许所有
request_header_access Pragma允许所有
request_header_access接受允许所有
request_header_access Accept-Charset允许所有
request_header_access接受 - 编码允许所有
request_header_access接受语言允许所有
request_header_access内容语言允许所有
request_header_access Mime-版本允许所有
request_header_access重试后允许所有
request_header_access标题允许所有
request_header_access连接允许所有
request_header_access代理连接允许所有
request_header_access用户代理允许所有
request_header_access Cookie允许all
request_header_access所有拒绝所有
通过关闭
forwarded_for off
follow_x_forwarded_for拒绝所有
acl vinte1随机1/5
acl vinte2 random 1/5
acl vinte3随机1/5
acl vinte4随机1/5
acl vinte5随机1/5
tcp_outgoing_address 1.1.1.1 vinte1# fake ip's,替换为你的
tcp_outgoing_address 1.1.1.2 vinte2
tcp_outgoing_address 1.1.1.3 vinte3
tcp_outgoing_address 1.1.1.4 vinte4
tcp_outgoing_address 1.1.1.5 vinte5
tcp_outgoing_address 1.1.1.6#这将是默认tcp传出地址
a squid proxy:
$ proxy =1.1.1.1:33333;
$ useragent =Mozilla / 5.0(Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1)Gecko / 20061204 Firefox / 2.0.0.1;
$ url =https://api.ipify.org/;
$ ch = curl_init();
curl_setopt($ ch,CURLOPT_CONNECTTIMEOUT,15);
curl_setopt($ ch,CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1');
curl_setopt($ ch,CURLOPT_HTTPPROXYTUNNEL,1);
curl_setopt($ ch,CURLOPT_PROXY,$ proxy);
curl_setopt($ ch,CURLOPT_PROXYUSERPWD,'USER:PASS');
curl_setopt($ ch,CURLOPT_USERAGENT,$ useragent);
curl_setopt($ ch,CURLOPT_URL,$ url);
curl_setopt($ ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ ch,CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ ch,CURLOPT_SSL_VERIFYPEER,0);
$ result = curl_exec($ ch);
curl_close($ ch);
echo $ result
Usefull链接: 我发现这是旋转代理的最可靠和安全的方法,因为你不依赖第三方代理提供商和您的信息(密码,数据等)将更安全。 Has anyone of you tried using rotating proxies? How easy is this to implement? Does it work well? Your experience please PS: i see questions like "how to make php script use a list of proxies" gather a lot of minuses. Can you explain this before putting -1? ------ UPDATED 04 March 2017 ------- I've been there and found that the best solution was: If you don't have a dedicated server or at least a vps and a little patience don't bother to read the rest of the post ... 1 - Install Squid 3.2 from source (check notes below) This way you don't need to rotate the list of ip's on your php script, instead, you'll be connecting to the same ip (ex: 192.168.1.1:3129) but the visible outgoing ip ( You'll need to compile squid 3.2 with Step by Step Install: Sample squid.conf (located in this case /squid32/etc/squid.conf) : Sample PHP CURL request using a squid proxy: Usefull Links: I've found this to be the most reliable and secure way to rotate proxies because you don't rely on third party proxy providers and your information (passwords, data, etc) will be safer.It may sound a little difficult to setup at first but it will pay off every second you've spent, GL :) 这篇关于PHP和旋转代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
Squid 3.2源:
Rotating_three_IPs :
AclRandom :
在CentOS 5.3上安装Squid 3.2 -
向Squid添加密码:如何使用基本的用户名和密码验证来设置squid代理? p>
它可能听起来有点难以设置,但它会付清你花费的每一秒,GL :)
2 - Add a list of 20 or so ip's to squid.conf (costs about 25$ month)
3 - Use the the new feature ACLrandom to rotate the outgoing ip. tcp_outgoing_address
) will rotate on every request based on the random settings .'-enable-http-violations'
in order to make it an elite anonymous proxy. yum -y groupinstall 'Development Tools'
yum -y install openssl-devel
mkdir /meus
cd /meus
wget http://www.squid-cache.org/Versions/v3/3.2/squid-3.2.13.tar.gz
tar -xvf squid-3.2.13.tar.gz
cd squid-3.2.13
./configure -prefix=/squid32 '--enable-removal-policies=heap,lru' '--enable-ssl' '--with-openssl' '--enable-linux-netfilter' '--with-pthreads' '--enable-ntlm-auth-helpers=SMB,fakeauth' '--enable-external-acl-helpers=ip_user,ldap_group,unix_group,wbinfo_group' '--enable-auth-basic' '--enable-auth-digest' '--enable-auth-negotiate' '--enable-auth-ntlm' '--with-winbind-auth-challenge' '--enable-useragent-log' '--enable-referer-log' '--disable-dependency-tracking' '--enable-cachemgr-hostname=localhost' '--enable-underscores' '--enable-build-info' '--enable-cache-digests' '--enable-ident-lookups' '--enable-follow-x-forwarded-for' '--enable-wccpv2' '--enable-fd-config' '--with-maxfd=16384' '-enable-http-violations'
make
make install
#this will be the ip and port where squid will run
http_port 5.5.5.5:33333 # change this ip and port ...
#Extra parameters on squid.conf to make an elite proxy
request_header_access Allow allow all
request_header_access Authorization allow all
request_header_access WWW-Authenticate allow all
request_header_access Proxy-Authorization allow all
request_header_access Proxy-Authenticate allow all
request_header_access Cache-Control allow all
request_header_access Content-Encoding allow all
request_header_access Content-Length allow all
request_header_access Content-Type allow all
request_header_access Date allow all
request_header_access Expires allow all
request_header_access Host allow all
request_header_access If-Modified-Since allow all
request_header_access Last-Modified allow all
request_header_access Location allow all
request_header_access Pragma allow all
request_header_access Accept allow all
request_header_access Accept-Charset allow all
request_header_access Accept-Encoding allow all
request_header_access Accept-Language allow all
request_header_access Content-Language allow all
request_header_access Mime-Version allow all
request_header_access Retry-After allow all
request_header_access Title allow all
request_header_access Connection allow all
request_header_access Proxy-Connection allow all
request_header_access User-Agent allow all
request_header_access Cookie allow all
request_header_access All deny all
via off
forwarded_for off
follow_x_forwarded_for deny all
acl vinte1 random 1/5
acl vinte2 random 1/5
acl vinte3 random 1/5
acl vinte4 random 1/5
acl vinte5 random 1/5
tcp_outgoing_address 1.1.1.1 vinte1 # fake ip's , replace with yours
tcp_outgoing_address 1.1.1.2 vinte2
tcp_outgoing_address 1.1.1.3 vinte3
tcp_outgoing_address 1.1.1.4 vinte4
tcp_outgoing_address 1.1.1.5 vinte5
tcp_outgoing_address 1.1.1.6 # this will be the default tcp outgoing address
$proxy = "1.1.1.1:33333";
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$url = "https://api.ipify.org/";
$ch = curl_init();
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,15);
curl_setopt($ch, CURLOPT_HTTP_VERSION,'CURL_HTTP_VERSION_1_1' );
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($ch, CURLOPT_PROXY, $proxy);
curl_setopt($ch, CURLOPT_PROXYUSERPWD,'USER:PASS');
curl_setopt($ch, CURLOPT_USERAGENT,$useragent);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,0);
$result=curl_exec ($ch);
curl_close ($ch);
echo $result
Squid 3.2 Source : http://www.squid-cache.org/Versions/v3/3.2/squid-3.2.13.tar.gz
Rotating_three_IPs : http://wiki.squid-cache.org/ConfigExamples/Strange/RotatingIPs#Example:_Rotating_three_IPs_based_on_time_of_day
AclRandom : http://wiki.squid-cache.org/Features/AclRandom
Installing Squid 3.2 on CentOS 5.3 - http://www.guldmyr.com/blog/installing-squid-3-2-on-centos-5-3/
Add password to Squid: How to set up a squid Proxy with basic username and password authentication?