![想要在 Ubuntu 22.04 中使用 squid 代理阻止下载 .doc、.dat、.mp3、.wav、.avi、.rar、.exe 等文件](https://linux22.com/image/1200205/%E6%83%B3%E8%A6%81%E5%9C%A8%20Ubuntu%2022.04%20%E4%B8%AD%E4%BD%BF%E7%94%A8%20squid%20%E4%BB%A3%E7%90%86%E9%98%BB%E6%AD%A2%E4%B8%8B%E8%BD%BD%20.doc%E3%80%81.dat%E3%80%81.mp3%E3%80%81.wav%E3%80%81.avi%E3%80%81.rar%E3%80%81.exe%20%E7%AD%89%E6%96%87%E4%BB%B6.png)
我想在 Ubuntu 22.04 中使用 squid 代理阻止下载 .doc、.dat、.mp3、.wav、.avi .rar、.exe 等文件,但无法做到,已经尝试了许多带有 urlpath_regex 参数的选项。示例如下:-
acl block_exe url_regex .*\.exe$
http_access deny block_exe
------------------------
Blocking file types in squid
First of all, create an ACL file includes all the file types to block downloading them.
[root@server ~]# vi /etc/squid/bad_files.acl
\.[Ee][Xx][Ee]$ #block downloading exe executable files
\.[Mm][Pp]3 $ #Block mp3 music files
\.[Zz][Ii][Pp]$ #Block ZIP archive files
\.[Jj][Pp][Ee][Gg]$ #Block jpeg picture files
\.[Aa][Vv][Ii]$ #Block avi video files
\.[Tt][Oo][Rr][Rr][Ee][Nn][Tt]$ #Block torrent files
#(Add the above required file extensions types and save the file)
然后,编辑 squid 配置文件并为上面创建的 acl 文件添加 ACL。
acl badfiles urlpath_regex "/etc/squid/bad_files.acl" (ACL for blocked file types)
http_access deny badfiles lan (Deny the file types to lan)
#(Add the above three lines and save the squid.conf file)