squid 用户通过NCSA认证

Squid的用户认证设置

  默认时,Squid本身不带任何认证程序,但是可以通过外部认证程序来实现用户认证。一般有以下的认证程序:LDAP认证、SMB认证、基于mysql的认证、 基于sock5的密码认证和基于Radius的认证。下面介绍常用的ncsa实现的认证, ncsa是Squid源代码包自带的认证程序之一,实现步骤如下:
1. 进入/usr/local/squid/auth_modules/NCSA目录,执行:
make
make install
2. 编译成功后,会生成ncsa_auth的可执行文件,拷贝生成的可执行文件到/usr/bin目录下。
3. 修改squid.conf文件的相关选项。
acl auth_user proxy_auth REQUIRED
http_access allow auth_user
authenticate_program /usr/local/squid/bin/ncsa_auth
/usr/local/squid/etc/passwd
4 利用Apache携带的工具软件htpasswd在/usr/local/squid/etc下生成密码文件,并添加相应的用户信息。该密码文件每行包含一个用户的信息,即用户名和密码。例如,用htpasswd生成密码文件passwd并添加用户me:

htpasswd -C /usr/local/squid/etc/passwd me

第一次加-C

生成的密码文件类似如下:

me:xxxxxxxxxxx


5 重新启动Squid,密码认证生效。

++++++++++++++++++++++++++++++++++
Squid 2.4版及以下的squid.conf中,包括以下几个相关选项:
authenticate_program /usr/lib/squid/ncsa_auth /etc/squid/password
authenticate_children 5
proxy_auth_realm Squid proxy-caching web server
authenticate_ttl 1 hour
acl normal proxy_auth REQUIRED
acl normal src 192.168.0.1/24
http_access allow ck
Squid 2.5在认证处理上有了较大的改变。
在2.5版的squid.conf中,包括以下几个相关选项:
#该选项指出了认证方式(basic)、需要的程序(ncsa_auth)和
对应的密码文件(password)
auth_param basic program /usr/bin/ncsa_auth /var/squid/etc/password
# 指定认证程序的进程数
auth_param basic children 5
# 浏览器显示输入用户/密码对话框时的领域内容
auth_param basic realm My Proxy Caching Domain
# 基本的认证有效时间
auth_param basic credentialsttl 2 hours
# 普通用户需要通过认证才能访问Internet
acl normal proxy_auth REQUIRED
http_access allow normal
其中password 文件使用apache的 htpasswd命令生成
下面是设置好的squid.conf的全部
http_port 3128
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
no_cache deny QUERY
cache_mem 64 MB
authenticate_program /usr/lib/squid/ncsa_auth /etc/squid/password
authenticate_children 32
proxy_auth_realm Squid proxy-caching web server
authenticate_ttl 24 hour
acl pwd proxy_auth REQUIRED
acl all src 0.0.0.0/0.0.0.0
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 443 563
acl Safe_ports port 80          # http
acl Safe_ports port 21          # ftp
acl Safe_ports port 443 563     # https, snews
acl Safe_ports port 70          # gopher
acl Safe_ports port 210         # wais
acl Safe_ports port 1025-65535  # unregistered ports
acl Safe_ports port 280         # http-mgmt
acl Safe_ports port 488         # gss-http
acl Safe_ports port 591         # filemaker
acl Safe_ports port 777         # multiling http
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access allow !Safe_ports Safe_ports !SSL_ports SSL_ports
http_access allow localhost
http_access allow pwd
http_access deny all

icp_access allow all

http://linux.chinaunix.net/techdoc/system/2007/01/07/947523.shtml


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值