文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>用Squid控制网站访问的时间和内容

用Squid控制网站访问的时间和内容

时间:2006-08-22  来源:nothing9

In the office I needed a way to block some websites permanently and others outside of break times. After looking at some inline solutions I realised that I could easily do what was needed with squid alone. Here's how

I created the following ACLs in squid's config file :

acl blockedsites url_regex -i "/etc/squid/blocked.txt"
acl bannedsites url_regex -i "/etc/squid/banned.txt"

acl lunchtime time MTWHF 12:15-13:45

The I can apply these ACLs near the end of my squid ACL rules:

http_access allow managers
http_access deny blockedsites !lunchtime
http_access deny bannedsites
http_access allow domainusers
http_access deny all

I use squid authentication here - the managers ACL refers to special users that have no restrictions. Making sure this is before the restrictive ACLs means it is applied and matched first. The domainusers ACL refers to any authorized users - unauthorized users are denied all access.

So, you can see that the access is denied to both ACLs, and the blockedsites ACL has an exception of !lunchtime. This means deny access while its not lunchtime - ACLs applied on the same line are logically ANDed.

The entries in the /etc/squid/blocked.txt and /etc/squid/banned.txt files are simple:

ebay
planetfootball.com
bigbrother.channel4.com

These are url_regex and because I keep them simple like this, the occurrence of, for example, ebay anywhere in the URL will match and therefore be denied.

When a new entry is added to either of the files it's a simple matter of "/etc/init.d/squid reload" to force squid to see the changes.

相关阅读 更多 +
排行榜 更多 +
末日枪战精英手机版

末日枪战精英手机版

飞行射击 下载
末日模拟生存最新版

末日模拟生存最新版

飞行射击 下载
末日求生枪战安卓版

末日求生枪战安卓版

飞行射击 下载