上一篇文章用windows+ squid 2.7做了windows平台的http代理,这一篇用Debian 8 64位和squid 3.x来做。
首先安装squid:
apt-get update apt-get install squid3
然后编辑配置文件:
nano /etc/squid3/squid.conf
内容更简单了:
acl all src all auth_param basic program /usr/lib/squid3/basic_ncsa_auth /etc/squid3/user.txt auth_param basic children 5 auth_param basic realm Welcome to my proxy server #端口相关的,如果不想限制,可以屏蔽这几行 # 定义端口 acl Safe_ports port 80 8080 443 # http # 拒绝所有非法端口,如果你不想做限制,可以屏蔽下面这行 http_access deny !Safe_ports # 定义授权组 acl squid_user proxy_auth REQUIRED # 允许授权组 http_access allow squid_user # 拒绝其它所有未定义的 http_access deny all # Squid 端口 http_port 0.0.0.0:5555 #http_reply_access allow all #http_port 80 transparent # vhost vport http11 #no_cache allow all hierarchy_stoplist cgi-bin ? cache_mem 0 MB cache_swap_low 90 cache_swap_high 95 maximum_object_size 20 MB maximum_object_size_in_memory 8 MB ipcache_size 2048 fqdncache_size 2048 reload_into_ims on strip_query_terms off access_log none visible_hostname cdn1.tingtao.org error_directory /usr/share/squid3/errors/zh-cn
然后重启一下squid3:
/etc/init.d/squid3 restart
来添加用户,与上篇文章一样,第一个用户要加 -c参数
htpasswd -c /etc/squid3/user.txt 用户名1
第二个就不需要了:
htpasswd /etc/squid3/user.txt 用户名2
最后呢,跟上篇文章需要说明的一致,squid本身是个明文代理,建议参考《Debian 7(Wheezy)/Ubuntu上使用stunnel+kingate配置加密代理》这篇文章做成加密代理。
后续补充:
经测试,用起来有点问题,一访问google就立马被墙了,过几分钟自动解封,再试,再封……
所以,还是建议各位搞个加密代理靠谱。
另外,访问google很痛苦,因为ipv6的缘故,所以需要关闭之:
编辑 /etc/sysctl.conf,加入下面3行:
net.ipv6.conf.all.disable_ipv6=1 net.ipv6.conf.default.disable_ipv6=1 net.ipv6.conf.lo.disable_ipv6=1
然后重启一下就好了。