参考URL:
https://www.cnblogs.com/vijayfly/p/5800038.html
https://www.cnblogs.com/operaculus/p/5705184.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
今晚又测试了SQUID作国内代理服务器,用户名密码登陆使用代码,高匿代理
大概步骤如下:
一,安装好squid软件。
二,安装好可使用htpasswd命令的软件(ubuntu和centos可能不一样)。
三,使用htpasswd -c /etc/squid/passwd [用户名],输入密码之后,为squid产生登陆用户名和密码。
四,编辑/etc/squid/squid.conf文件,注释掉那个acl之类的东东。
五,在/etc/squid/squid.conf的末尾,加入以下配置,用于用户登陆,缓存设置,高匿代码(注意第一行/usr/lib/squid/basic_ncsa_auth这个目录要对得上)。
auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/passwd acl auth_user proxy_auth REQUIRED http_access allow auth_user cache_mem MB maximum_object_size MB minimum_object_size KB maximum_object_size_in_memory KB cache_dir ufs /var/spool/squid cache_log /var/log/squid/cache.log access_log /var/log/squid/access.log logfile_rotate cache_swap_high cache_swap_low # Hide client ip # forwarded_for delete # Deny request for original source of a request follow_x_forwarded_for deny all # See below request_header_access X-Forwarded-For deny all request_header_access Via deny all
六,使用squid -k parse分析是否设置有错误。
七,squid -z进行初始化(这个命令神奇,要自己按回车键才会退出)。
八,使用service squid start启动服务。
九,查看3128端口开启,如果有防火墙,开启端口,如果阿里在安全组,在管理控制台里开启进入端口。
十,在浏览器里设置代理,跳出用户名密码框,输入正确后,用于验证服务。
十一,以下两个bat脚本,用于在win里自动启用和关闭代码。
@echo off echo 开始设置IE代理上网 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 1 /f reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "代理服务器:3128" /f echo 代理设置完成按任意键关闭 pause>nul
@echo off REM 声明采用UTF-8编码 chcp 65001 echo 开始清除IE代理设置 reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /t REG_DWORD /d 0 /f reg add "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyServer /d "" /f echo IE代理清楚完成按任意键关闭 pause>nul