一、在/usr/local/squid/etc/squid.conf(具体位置要看编译时的prefix参数),注意和cache manager相关的行:
我们需要在acl指令、http_access指令和cachemgr_passwd指令都添加相关的参数。
起作用的是以下的指令:
acl localhost src 127.0.0.1/255.255.255.255
acl manager proto cache_object
# 允许本地用户清除缓存
acl Purge method PURGE
http_access allow Purge localhost
http_access deny Purge
# Only allow cachemgr access from localhost
http_access allow manager localhost
http_access deny manager
# 对于查看配置,关闭Squid等这类重要操作禁用掉
cachemgr_passwd disable config shutdown authenticator offline_toggle
# 对于不大查询的操作使用不使用密码
cachemgr_passwd none info stats/objects
# 对于其它操作密码保护
# cachemgr_passwd secretP all
二、检验我们的配置
访问不需要密码的项:
或者
访问需要密码的项:
注:该命令常用来有权限访问的项
或者
删除缓存:
下面是默认的权限(未做配置):
# squidclient -p80 -h www.xxx.xxx mgr:
HTTP/1.0 200 OK
Server: squid/2.6.STABLE10
Date: Sat, 26 Mar 2011 14:41:47 GMT
Content-Type: text/plain
Expires: Sat, 26 Mar 2011 14:41:47 GMT
Last-Modified: Sat, 26 Mar 2011 14:41:47 GMT
X-Cache: MISS from webcache
X-Cache-Lookup: MISS from webcache:80
Via: 1.0 webcache:80 (squid/2.6.STABLE10)
Proxy-Connection: close
memMemory Utilization public
cbdata Callback Data Registry Contents public
events Event Queue public
squidaio_countsAsync IO Function Counters public
config Current Squid Configuration hidden
ipcacheIP Cache Stats and Contents public
fqdncache FQDN Cache Stats and Contents public
idns Internal DNS Statistics public
external_acl External ACL stats public
http_headers HTTP Header Statistics public
menu This Cachemanager Menu public
shutdown Shut Down the Squid Process hidden
offline_toggle Toggle offline_mode setting hidden
info General Runtime Information public
filedescriptorsProcess Filedescriptor Allocation public
objectsAll Cache Objects public
vm_objects In-Memory and In-Transit Objectspublic
openfd_objects Objects with Swapout files open public
pending_objectsObjects being retreived from the networkpublic
client_objects Objects being sent to clients public
io Server-side network read() size histograms public
counters Traffic and Resource Counters public
peer_selectPeer Selection Algorithms public
digest_stats Cache Digest and ICP blob public
5min 5 Minute Average of Counterspublic
60min 60 Minute Average of Counters public
utilizationCache Utilization public
histograms Full Histogram Counts public
active_requestsClient-side Active Requests public
store_digest Store Digestpublic
storedir Store Directory Stats public
store_check_cachable_stats storeCheckCachable() Stats public
store_io Store IO Interface Statspublic
pconn Persistent Connection Utilization Histogramspublic
refreshRefresh Algorithm Statisticspublic
delay Delay Pool Levels public
forwardRequest Forwarding Statistics public
client_listCache Client List public
asndb AS Number Database public
server_listPeer Cache Statistics public
即:
默认设置hidden的项为:
config shutdown offline_toggle
它的含意是,如果服务端不配置密码,将不能被访问,默认是隐藏的。
这不同于配置为,这样不允许客户端访问这几个项,访问时状态为disable
http_access disable config shutdown offline_toggle
这也不同于被配置为hidden,这样也不允许客户端访问这几个项,不过访问时状态为protected
http_access protected config shutdown offline_toggle
三、配置允许以哪些域名和端口访问cache manager
修改/usr/local/squid/etc/squid/etc/cachemgr.conf(文件位置依赖于我们的编译选项)文件,增加Host:Port的行。
例如我的配置: