免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2216 | 回复: 0
打印 上一主题 下一主题

[proxy] 1个squid3.2配置 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-11-04 12:09 |只看该作者 |倒序浏览
本帖最后由 kkkggg 于 2013-11-04 12:24 编辑

备忘一下
freebsd+squid透明代理
限制普通用户在工作时间的下载文件类型、文件大小、网址。
  1. #
  2. # Recommended minimum configuration:
  3. #

  4. # Example rule allowing access from your local networks.
  5. # Adapt to list your (internal) IP networks from where browsing
  6. # should be allowed
  7. acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
  8. acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
  9. acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
  10. acl localnet src fc00::/7 # RFC 4193 local private network range
  11. acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines

  12. acl SSL_ports port 443
  13. acl Safe_ports port 80 # http
  14. acl Safe_ports port 21 # ftp
  15. acl Safe_ports port 443 # https
  16. acl Safe_ports port 70 # gopher
  17. acl Safe_ports port 210 # wais
  18. acl Safe_ports port 1025-65535 # unregistered ports
  19. acl Safe_ports port 280 # http-mgmt
  20. acl Safe_ports port 488 # gss-http
  21. acl Safe_ports port 591 # filemaker
  22. acl Safe_ports port 777 # multiling http
  23. acl CONNECT method CONNECT
  24. acl unlimited_client src 10.0.1.32/32
  25. acl working_time_am time MTWHFA 6:30-12:20
  26. acl working_time_pm time MTWHFA 12:50-18:10
  27. acl working_website dstdom_regex -i 10086.cn 95599.cn abchina.com adobe.com apple.com avg.com avira.com boc.cn ccb.com cgbchina.com.cn cmbchina.com fetion.com.cn gov.cn gov.hk icbc.com iegallery.com live.com maps.google.com(\.hk)? microsoft.com mozilla.net mydrivers.com passport.net psbc.com translate.google.com(\.hk)? web.qq.com (www[0-9]?\.)+baidu.com www.google.com(\.hk)? ydstatic.com youdao.com
  28. acl prohibited_url url_regex -i ://(.+\.)*56.com/ ://(.+\.)*cntv.cn/ ://(.+\.)*funshion.com/ ://(.+\.)*haoetv.com/ ://(.+\.)*imgo.tv/ ://(.+\.)*joy.cn/ ://(.+\.)*jstv.com/ ://(.+\.)*ku6.com/ ://(.+\.)*letv.com/ ://(.+\.)*pipi.cn/ ://(.+\.)*pps.tv/ ://(.+\.)*pptv.com/ ://(.+\.)*qiyi.com/ ://(.+\.)*game.qq.com/ ://(.+\.)*qqgame.qq.com ://(.+\.)*user.qzone.qq.com/ ://(.+\.)*qzone.com/ ://(.+\.)*soku.com/ ://(.+\.)*tudou.com/ ://(.+\.)*tv.sohu.com/ ://(.+\.)*uusee.com/ ://(.+\.)*video.baidu.com/ ://(.+\.)*xunlei.com/ ://(.+\.)*youku.com/
  29. acl general_client src 10.0.0.2-10.0.2.254/32
  30. acl limited_client src 10.0.2.5/32
  31. acl prohibited_file_types urlpath_regex -i \.avi$ \.bat$ \.exe$ \.flv$ \.gz$ \.mp3$ \.mp4$ \.mpeg$ \.mpg$ \.pif$ \.ra$ \.rar$ \.rm$ \.rmvb$ \.wma$ \.wmv$ \.wav$ \.zip$
  32. acl no_cache url_regex -i ://(.+\.)*szaic.gov.cn/

  33. #
  34. # Recommended minimum Access Permission configuration:
  35. #
  36. # Only allow cachemgr access from localhost
  37. http_access allow manager localhost
  38. http_access deny manager

  39. # Deny requests to certain unsafe ports
  40. http_access deny !Safe_ports

  41. # Deny CONNECT to other than secure SSL ports
  42. http_access deny CONNECT !SSL_ports

  43. # We strongly recommend the following be uncommented to protect innocent
  44. # web applications running on the proxy server who think the only
  45. # one who can access services on "localhost" is a local user
  46. #http_access deny to_localhost

  47. #
  48. # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
  49. #

  50. # Example rule allowing access from your local networks.
  51. # Adapt localnet in the ACL section to list your (internal) IP networks
  52. # from where browsing should be allowed
  53. http_access allow localhost
  54. http_access allow unlimited_client
  55. http_access allow working_website
  56. http_access deny working_time_am prohibited_url general_client
  57. http_access deny working_time_pm prohibited_url general_client
  58. http_access deny working_time_am general_client prohibited_file_types
  59. http_access deny working_time_pm general_client prohibited_file_types
  60. http_access deny limited_client
  61. http_access allow all

  62. # And finally deny all other access to this proxy

  63. # Squid normally listens to port 3128
  64. http_port 3128 transparent

  65. # Uncomment and adjust the following to add a disk cache directory.
  66. #cache_dir ufs /var/squid/cache 100 16 256
  67. cache_dir ufs /var/squid/cache 10000 16 256

  68. # Leave coredumps in the first cache dir
  69. coredump_dir /var/squid/cache

  70. # Add any of your own refresh_pattern entries above these.
  71. refresh_pattern ^ftp:                1440        20%        10080
  72. refresh_pattern ^gopher:        1440        0%        1440
  73. refresh_pattern -i (/cgi-bin/|\?) 0        0%        0
  74. refresh_pattern .                0        20%        4320
  75. cache_effective_user squid
  76. cache_effective_group squid
  77. reply_body_max_size 10 MB working_time_am general_client !working_website !unlimited_client
  78. reply_body_max_size 10 MB working_time_pm general_client !working_website !unlimited_client
  79. forwarded_for off
  80. cache deny no_cache

  81. visible_hostname node1
复制代码
上面是用webmin的官方squid模块生成的。设置下载文件大小限制是在Cache Options页面的
Maximum reply body sizes            Size (kB)         For requests matching ACLs (leave empty for all)
这项下面。这个可以限制网页上的视频,不用知道网址也能限制。
第1个框填文件大小数字(纯数字,不要加单位)。第二个框最前面要填文件大小的单位(例如MB),接着是acl选择项。
例如:
10    MB working_time_am general_client !working_website !unlimited_client
10    MB working_time_pm general_client !working_website !unlimited_client
上面两行用途是限制普通用户在工作时间访问超过10MB大小的非工作网站。这样超过10MB大小的网页视频就打不开了。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP