squidclient服务端Squid的配置

简介:

 如何通过ACLcache manager指令控制客户端对Squid Web管理接口的访问?

一)在/usr/local/squid/etc/squid.conf(具体位置要看编译时的prefix参数),注意和cache manager相关的行:

 

 
  1. #Recommended minimum configuration: 
  2. acl all src 0.0.0.0/0.0.0.0 
  3. acl manager proto cache_object 
  4. acl localhost src 127.0.0.1/255.255.255.255 
  5. acl to_localhost dst 127.0.0.0/8 
  6. acl SSL_ports port 443 
  7. acl Safe_ports port 80 # http 
  8. acl Safe_ports port 21 # ftp 
  9. acl Safe_ports port 443 # https 
  10. acl Safe_ports port 70 # gopher 
  11. acl Safe_ports port 210 # wais 
  12. acl Safe_ports port 1025-65535 # unregistered ports 
  13. acl Safe_ports port 280 # http-mgmt 
  14. acl Safe_ports port 488 # gss-http 
  15. acl Safe_ports port 591 # filemaker 
  16. acl Safe_ports port 777 # multiling http 
  17. acl CONNECT method CONNECT 
  18.  
  19. # 
  20. # Only allow cachemgr access from localhost 
  21. http_access allow manager localhost 
  22. http_access deny manager 
  23. # Deny requests to unknown ports 
  24. http_access deny !Safe_ports 
  25. # Deny CONNECT to other than SSL ports 
  26. http_access deny CONNECT !SSL_ports 
  27.  
  28. # And finally deny all other access to this proxy 
  29. http_access deny all 
  30.  
  31.  
  32. # TAG: cachemgr_passwd 
  33. # Specify passwords for cachemgr operations. 
  34. # 
  35. # Usage: cachemgr_passwd password action action ... 
  36. # 
  37. # Some valid actions are (see cache manager menu for a full list): 
  38. # 5min 
  39. # 60min 
  40. # asndb 
  41. # authenticator 
  42. # cbdata 
  43. # client_list 
  44. # comm_incoming 
  45. # config * 
  46. # counters 
  47. # delay 
  48. # digest_stats 
  49. # dns 
  50. # events 
  51. # filedescriptors 
  52. # fqdncache 
  53. # histograms 
  54. # http_headers 
  55. # info 
  56. # io 
  57. # ipcache 
  58. # mem 
  59. # menu 
  60. # netdb 
  61. # non_peers 
  62. # objects 
  63. # offline_toggle * 
  64. # pconn 
  65. # peer_select 
  66. # redirector 
  67. # refresh 
  68. # server_list 
  69. # shutdown * 
  70. # store_digest 
  71. # storedir 
  72. # utilization 
  73. # via_headers 
  74. # vm_objects 
  75. # 
  76. # * Indicates actions which will not be performed without a 
  77. # valid password, others can be performed if not listed here. 
  78. # 
  79. # To disable an action, set the password to "disable". 
  80. # To allow performing an action without a password, set the 
  81. # password to "none". 
  82. # 
  83. # Use the keyword "all" to set the same password for all actions. 
  84. # 
  85. #Example: 
  86. # cachemgr_passwd secret shutdown 
  87. # cachemgr_passwd lesssssssecret info stats/objects 
  88. # cachemgr_passwd disable all 
  89. # 
  90. #Default: 
  91. # none 

我们需要在acl指令、http_access指令和cachemgr_passwd指令都添加相关的参数。

起作用的是以下的指令:

 

 
  1. acl localhost src 127.0.0.1/255.255.255.255 
  2. acl manager proto cache_object 
  3. # 允许本地用户清除缓存 
  4. acl Purge method PURGE 
  5. http_access allow Purge localhost 
  6. http_access deny Purge 
  7. # Only allow cachemgr access from localhost 
  8. http_access allow manager localhost 
  9. http_access deny manager 
  10. # 对于查看配置,关闭Squid等这类重要操作禁用掉 
  11. cachemgr_passwd disable config shutdown authenticator offline_toggle 
  12. # 对于不大查询的操作使用不使用密码 
  13. cachemgr_passwd none info stats/objects 
  14. # 对于其它操作密码保护 
  15. # cachemgr_passwd secretP all 

二)检验我们的配置

访问不需要密码的项:


 
  1. squidclient -p80 cache_object://localhost/info 

或者


 
  1. squidclient -p80 -h localhost mgr:info 

访问需要密码的项:

 
  1. squidclient -p80 cache_object://localhost/menu@secretP 

注:该命令常用来有权限访问的项

或者


 
  1. squidclient -p80 -h localhost mgr:menu@secretP 

删除缓存:


 
  1. squidclient -m PURGE http://url 

 

下面是默认的权限(未做配置):


 
  1. # squidclient -p80 -h localhost mgr:menu@secretP 
  2. HTTP/1.0 200 OK 
  3. ... 此处省略部分内容 
  4. mem Memory Utilization protected 
  5. cbdata Callback Data Registry Contents protected 
  6. events Event Queue protected 
  7. squidaio_counts Async IO Function Counters protected 
  8. config Current Squid Configuration disabled 
  9. ipcache IP Cache Stats and Contents protected 
  10. fqdncache FQDN Cache Stats and Contents protected 
  11. idns Internal DNS Statistics protected 
  12. external_acl External ACL stats protected 
  13. http_headers HTTP Header Statistics protected 
  14. menu This Cachemanager Menu protected 
  15. shutdown Shut Down the Squid Process disabled 
  16. offline_toggle Toggle offline_mode setting disabled 
  17. info General Runtime Information public 
  18. filedescriptors Process Filedescriptor Allocation protected 
  19. objects All Cache Objects protected 
  20. vm_objects In-Memory and In-Transit Objects protected 
  21. openfd_objects Objects with Swapout files open protected 
  22. pending_objects Objects being retreived from the network protected 
  23. client_objects Objects being sent to clients protected 
  24. io Server-side network read() size histograms protected 
  25. counters Traffic and Resource Counters public 
  26. peer_select Peer Selection Algorithms protected 
  27. digest_stats Cache Digest and ICP blob protected 
  28. 5min 5 Minute Average of Counters protected 
  29. 60min 60 Minute Average of Counters protected 
  30. utilization Cache Utilization protected 
  31. histograms Full Histogram Counts protected 
  32. active_requests Client-side Active Requests protected 
  33. store_digest Store Digest protected 
  34. storedir Store Directory Stats protected 
  35. store_check_cachable_stats storeCheckCachable() Stats protected 
  36. store_io Store IO Interface Stats protected 
  37. pconn Persistent Connection Utilization Histograms protected 
  38. refresh Refresh Algorithm Statistics protected 
  39. delay Delay Pool Levels protected 
  40. forward Request Forwarding Statistics protected 
  41. client_list Cache Client List protected 
  42. netdb Network Measurement Database protected 
  43. asndb AS Number Database protected 
  44. server_list Peer Cache Statistics protected 
  45. non_peers List of Unknown sites sending ICP messages protected 

即:

默认设置hidden的项为:

 
  1. config shutdown offline_toggle 

它的含意是,如果服务端不配置密码,将不能被访问,默认是隐藏的。

这不同于配置为,这样不允许客户端访问这几个项,访问时状态为disable

 
  1. http_access disable config shutdown offline_toggle 

这也不同于被配置为hidden,这样也不允许客户端访问这几个项,不过访问时状态为protected

 
  1. http_access protected config shutdown offline_toggle 

三)配置允许以哪些域名和端口访问cache manager

修改/usr/local/squid/etc/squid/etc/cachemgr.conf(文件位置依赖于我们的编译选项)文件

,增加Host:Port的行。

例如我的配置:

# grep ^[^#] /etc/squid/etc/cachemgr.conf

 
  1. localhost:80 
  2. 192.168.88.51:80 
  3. squid01.wangxiaoyu.org:80 



本文转自xiaoyuwang 51CTO博客,原文链接:http://blog.51cto.com/wangxiaoyu/527265 ,如需转载请自行联系原作者




相关文章
|
计算机视觉 数据格式
使用opencv在Qt控件上播放mp4文件
使用opencv在Qt控件上播放mp4文件
378 2
|
网络协议 Linux Docker
在centos7下通过docker 安装onlyoffice
在centos7下通过docker 安装onlyoffice
1379 0
|
数据安全/隐私保护 Windows
限制访问网站、过滤特定网址、禁止访问指定网站的方法
许多公司出于管理员工上网行为的需要,经常限制电脑访问一些网站例如游戏网站、购物网站或是视频网站等等
1172 3
|
数据采集 Web App开发 JavaScript
python-selenium模块详解!!!
Selenium 是一个强大的自动化测试工具,支持 Python 调用浏览器进行网页抓取。本文介绍了 Selenium 的安装、基本使用、元素定位、高级操作等内容。主要内容包括:发送请求、加载网页、元素定位、处理 Cookie、无头浏览器设置、页面等待、窗口和 iframe 切换等。通过示例代码帮助读者快速掌握 Selenium 的核心功能。
1251 5
|
数据采集 JSON 关系型数据库
将 MySQL 数据抽取并写入 DataHub
将 MySQL 数据抽取并写入 DataHub
554 3
|
XML JSON 数据格式
XmlRPC协议详解(一款不支持原生异步请求的协议)
XmlRPC是一种基于XML(eXtensible Markup Language)的远程过程调用协议。它使用简单的文本格式进行通信,将请求和响应数据封装在XML中,广泛应用于Web服务和分布式系统中。
637 0
|
算法 NoSQL 关系型数据库
【Spring Cloud系列】 雪花算法原理及实现
【Spring Cloud系列】 雪花算法原理及实现
1081 0
|
前端开发 安全 Shell
对象准备入手前端开发,我连夜给ta准备了这篇git指南之终极奥义
对象是真的,连夜码字是真的,Git指南也是真的
424 0
对象准备入手前端开发,我连夜给ta准备了这篇git指南之终极奥义
|
XML SQL 消息中间件
秋招面试题系列- - -Java工程师(四)
​ 目录 MyBatis面试题 16、Xml映射文件中,除了常见的 select|insert|updae|delete标签之外,还有哪些标签? 答:<resultMap>、<parameterMap>、<sql>、<include>、<selectKey>,加上动态 sql的 9个标签,其中为 sql片段标签,通过<include>标签引入 sql片段,<selectKey>为不支持自增的主键生成策略标签。 17、Mybatis的 Xml映射文件中,不同的 Xml映射文件,id是否可以重复? 不同的 Xml映射文件,如果配置了 namespace,那么 id可以重复;如果没
195 0
秋招面试题系列- - -Java工程师(四)

热门文章

最新文章