首页 > 世达工具代理 > 配置Squid代理通过账号密码验证

配置Squid代理通过账号密码验证

现在很多网络代理扫描工具都可以很快的扫描出我们搭建的代理,如果不想被人使用,可以设置squid通过账号密码来验证,这样即使扫描出了代理,没有账户密码就不怕别人蹭我们的代理了。

首先,安装配置好squid代理,这里为了简便,并没有配置太多的acl策略。

1[root@iZt4nbb1rjtnkcrx0p7ejzZ ~]# rpm -q squid
2squid-3.1.23-24.el6.x86_64
3[root@iZt4nbb1rjtnkcrx0p7ejzZ ~]#

配置文件,这里使用默认端口3128:

1[root@iZt4nbb1rjtnkcrx0p7ejzZ ~]# cat /etc/squid/squid.conf
2#
3# 使用帐号密码认证方式使用代理
4auth_param basic program /usr/lib64/squid/ncsa_auth /etc/squid/squid_user.txt
5auth_param basic children 5
6auth_param basic realm Welcome to pycredit's proxy-only web server
7
8# 定义授权组
9acl squid_user proxy_auth REQUIRED
10# Recommended minimum configuration:
11# 定义端口
12#
13acl SSL_ports port 443
14acl Safe_ports port 80 # http
15acl Safe_ports port 21 # ftp
16acl Safe_ports port 443 # https
17acl Safe_ports port 70 # gopher
18acl Safe_ports port 210 # wais
19acl Safe_ports port 1025-65535 # unregistered ports
20acl Safe_ports port 280 # http-mgmt
21acl Safe_ports port 488 # gss-http
22acl Safe_ports port 591 # filemaker
23acl Safe_ports port 777 # multiling http
24# 拒绝所有非定义的端口
25http_access deny !Safe_ports
26http_access allow squid_user
27# And finally deny all other access to this proxy
28http_access deny all
29
30# Squid normally listens to port 3128
31http_port 3128
32
33# Uncomment and adjust the following to add a disk cache directory.
34cache_dir ufs /var/spool/squid 100 16 256
35
36# Leave coredumps in the first cache dir
37coredump_dir /var/spool/squid
38
39# Add any of your own refresh_pattern entries above these.
40refresh_pattern ^ftp: 1440 20% 10080
41refresh_pattern ^gopher: 1440 0% 1440
42refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
43refresh_pattern . 0 20% 4320

上面的passwd文件需要使用htpasswd命令生成,如果没有这个命令需要使用http-tools工具,若没有安装httpd:

查看源代码打印帮助

1htpasswd -c /etc/squid/squid_user.txt fanxiaomo
2[root@iZt4nbb1rjtnkcrx0p7ejzZ ~]# htpasswd -c /etc/squid/</em>squid_user.txt fanxiaomo
3New password:
4Re-type new password:
5Adding password for user fanxiaomo

重启squid服务,在浏览器测试,使用的时候需要输入用户名和密码。

,可以参考五金工具的资料,