- 论坛徽章:
- 0
|
本帖最后由 kkkggg 于 2013-11-04 12:24 编辑
备忘一下
freebsd+squid透明代理
限制普通用户在工作时间的下载文件类型、文件大小、网址。- #
- # Recommended minimum configuration:
- #
- # Example rule allowing access from your local networks.
- # Adapt to list your (internal) IP networks from where browsing
- # should be allowed
- acl localnet src 10.0.0.0/8 # RFC1918 possible internal network
- acl localnet src 172.16.0.0/12 # RFC1918 possible internal network
- acl localnet src 192.168.0.0/16 # RFC1918 possible internal network
- acl localnet src fc00::/7 # RFC 4193 local private network range
- acl localnet src fe80::/10 # RFC 4291 link-local (directly plugged) machines
- acl SSL_ports port 443
- acl Safe_ports port 80 # http
- acl Safe_ports port 21 # ftp
- acl Safe_ports port 443 # https
- 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
- acl unlimited_client src 10.0.1.32/32
- acl working_time_am time MTWHFA 6:30-12:20
- acl working_time_pm time MTWHFA 12:50-18:10
- 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
- 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/
- acl general_client src 10.0.0.2-10.0.2.254/32
- acl limited_client src 10.0.2.5/32
- 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$
- acl no_cache url_regex -i ://(.+\.)*szaic.gov.cn/
- #
- # Recommended minimum Access Permission configuration:
- #
- # Only allow cachemgr access from localhost
- http_access allow manager localhost
- http_access deny manager
- # Deny requests to certain unsafe ports
- http_access deny !Safe_ports
- # Deny CONNECT to other than secure SSL ports
- http_access deny CONNECT !SSL_ports
- # We strongly recommend the following be uncommented to protect innocent
- # web applications running on the proxy server who think the only
- # one who can access services on "localhost" is a local user
- #http_access deny to_localhost
- #
- # INSERT YOUR OWN RULE(S) HERE TO ALLOW ACCESS FROM YOUR CLIENTS
- #
- # Example rule allowing access from your local networks.
- # Adapt localnet in the ACL section to list your (internal) IP networks
- # from where browsing should be allowed
- http_access allow localhost
- http_access allow unlimited_client
- http_access allow working_website
- http_access deny working_time_am prohibited_url general_client
- http_access deny working_time_pm prohibited_url general_client
- http_access deny working_time_am general_client prohibited_file_types
- http_access deny working_time_pm general_client prohibited_file_types
- http_access deny limited_client
- http_access allow all
- # And finally deny all other access to this proxy
- # Squid normally listens to port 3128
- http_port 3128 transparent
- # Uncomment and adjust the following to add a disk cache directory.
- #cache_dir ufs /var/squid/cache 100 16 256
- cache_dir ufs /var/squid/cache 10000 16 256
- # Leave coredumps in the first cache dir
- coredump_dir /var/squid/cache
- # Add any of your own refresh_pattern entries above these.
- refresh_pattern ^ftp: 1440 20% 10080
- refresh_pattern ^gopher: 1440 0% 1440
- refresh_pattern -i (/cgi-bin/|\?) 0 0% 0
- refresh_pattern . 0 20% 4320
- cache_effective_user squid
- cache_effective_group squid
- reply_body_max_size 10 MB working_time_am general_client !working_website !unlimited_client
- reply_body_max_size 10 MB working_time_pm general_client !working_website !unlimited_client
- forwarded_for off
- cache deny no_cache
- 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大小的网页视频就打不开了。
|
|