搭建ADSL自动拨号高匿代理池
adsl这种服务器网上有很多, 各位自己选择一个服务商购买就行.
搭建服务器环境: centos7 64位
首先购买后,连上服务器先进行拨号, 我这里的拨号命令是
pppoe-start
拨号完毕后, 先安装squid
yum install squid -y
之后编辑squid的配置文件
vi /etc/squid/squid.conf
用户名密码配置 在http_access deny all之前加上
auth_param basic program /usr/lib64/squid/basic_ncsa_auth /etc/squid/passwd
acl auth_user proxy_auth REQUIRED
http_access allow auth_user
修改默认的端口号 默认的端口号为3128
http_port 3128
文件最后加上高匿代理的配置
request_header_access X-Forwarded-For deny all
request_header_access From deny all
request_header_access Via deny all
之后安装htpasswd
yum -y install httpd-tools
配置用户名 密码
htpasswd -c /etc/squid/passwd 用户名
重启squid
service squid restart
将squid设置为开机自启
systemctl enable squid
防火墙开启squid的端口
firewall-cmd --zone=public --add-port=端口/tcp --permanent
重启防火墙 使配置生效
firewall-cmd --reload
装好之后可以写个python脚本测试一下是否可用
import requests
proxies = {
'http': 'http://刚设置的用户名:密码@代理服务器的ip:设置的端口号',
'https': 'https://刚设置的用户名:密码@代理服务器的ip:设置的端口号'
}
response = requests.get('http://httpbin.org/get', proxies=proxies)
print(response.text)
这里有一个python3在centos服务器上自动安装的脚本 忘记是在哪里搜到的 如果看到了可以告知我 我把链接附在下面
这个脚本直接上传到centos服务器 用自带的python执行就行
#coding=utf-8
import subprocess
import os,sys
def exe_cmd(cmd):
p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
while True:
next_line = p.stdout.readline()
return_line = next_line.decode("utf-8", "ignore")
if return_line == '' and p.poll() != None:
break
print(return_line)
stdout, stderr = p.communicate()
if p.returncode != 0:
return False
return True
def main():
print ("python 3.7.2 一键安装开始!")
backinfo = exe_cmd('ping -c 1 -w 1 www.baidu.com')
if backinfo == False:
print ("网络检测失败程序退出,请重新检测网络环境!")
sys.exit()
print ("网络连接正常!")
yum_jc = exe_cmd('yum list')
if yum_jc == False:
print ("yum 不可用,请先手动配置yum安装!")
sys.exit()
print ('yum安装检测可用!')
exe_cmd("yum install gcc -y")
exe_cmd("yum install openssl-devel bizp2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel -y")
exe_cmd("wget http://npm.taobao.org/mirrors/python/3.7.2/Python-3.7.2.tgz")
exe_cmd("tar -zxvf Python-3.7.2.tgz")
exe_cmd("mv Python-3.7.2 /usr/local/")
exe_cmd("rm -rf Python-3.7.2.tgz")
os.chdir('/usr/local/Python-3.7.2')
exe_cmd("./configure")
exe_cmd("make")
exe_cmd("make install")
print ("程序执行完成!输入python3 查看效果。")
if __name__ == '__main__':
main()
成功之后可以自己在服务器上写一个脚本自动拨号 之后将拨号成功的脚本发送至服务器,或者存到远程服务器的redis
这里说一下 如果是存到远程服务器的redis,每次拨号完程序redis连接会断开,需要重连一下redis
或者说可以用现成大佬们写好的 这里贴上崔大的github链接