鱿鱼代理配置允许少量的youtube网址

问题描述 投票:0回答:1

我想完全禁止youtube.com网站通过squid访问。封锁youtube后,我想允许少数100个youtube的网址通过squid访问。只允许访问教育类的视频。我的squid安装工作正常。但是我在url_regex部分卡住了。我不能允许几个youtube的网址。要么youtube被屏蔽,要么youtube被完全打开。这是我的 sqid 配置文件。

#
# 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.1.0/24 # 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 allowed_videos dstdomain "/etc/squid/allowed_videos"
acl blocked_sites dstdomain "/etc/squid/blocked_sites"
http_access allow allowed_videos
http_access deny blocked_sites !allowed_videos

#
# Recommended minimum Access Permission configuration:
#
# 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

# Only allow cachemgr access from localhost
http_access allow localhost manager
http_access deny manager

# 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 localnet
http_access allow localhost

# And finally deny all other access to this proxy
http_access deny all

# Squid normally listens to port 3128
http_port 3128

# Uncomment and adjust the following to add a disk cache directory.
cache_dir ufs /var/spool/squid 512 16 256

# Leave coredumps in the first cache dir
coredump_dir /var/spool/squid

#
# 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

允许的视频文件的内容如下.youtube.comwatch?v=6tO_isJQfCY。

被屏蔽的网站文件内容如下.youtube.com。

请帮助我,使我可以部分地允许通过鱿鱼访问YouTube视频。

squid
1个回答
0
投票
  • 你不能使用Squid Proxy作为防火墙进行内容过滤。
  • 鱿鱼浏览器 是很好的,谁想要过滤大量的URLS和网站与一个DB文件。
  • url_regex 对你来说不是好事,因为Youtube频道中含有未知字符。

因此,你应该使用一些应用程序或用Python开发代码来检查整个网站的内容,使其允许或拒绝你的客户。

但在这种情况下,我建议你手动允许URL(如白名单)。

这是你想要的示例代码。

  • 首先将URLS保存在文件中:"etcsquidmywhitelist.txt"

  • 那么你就应该像这段代码一样只允许你的客户使用这个文件。

acl youtube_access src "/etc/squid/mywhitelist.txt"
http_access allow youtube_access
http_access deny all
© www.soinside.com 2019 - 2024. All rights reserved.