I have this rule to block extensions:
acl bl_ext url_regex -i "/path_to/bl_ext.txt"
http_access deny workdays bl_ext
Example content file "bl_ext.txt":
\.avi([a-zA-Z][0-9]*)?(\?.*)?$
\.m4a([a-zA-Z][0-9]*)?(\?.*)?$
\.m4r([a-zA-Z][0-9]*)?(\?.*)?$
\.m4v([a-zA-Z][0-9]*)?(\?.*)?$
\.mid([a-zA-Z][0-9]*)?(\?.*)?$
\.mov([a-zA-Z][0-9]*)?(\?.*)?$
\.mp3([a-zA-Z][0-9]*)?(\?.*)?$
\.mp4([a-zA-Z][0-9]*)?(\?.*)?$
\.mpeg4([a-zA-Z][0-9]*)?(\?.*)?$
\.mpeg([a-zA-Z][0-9]*)?(\?.*)?$
\.mpegps([a-zA-Z][0-9]*)?(\?.*)?$
\.mpg([a-zA-Z][0-9]*)?(\?.*)?$
#etc, etc, etc
And this rule to block mime_type:
acl bl_mt rep_mime_type -i "/path_to/bl_mt.txt"
http_reply_access deny bl_mt
Example content file "bl_mimetype.txt":
^audio/mp4$
^audio/mpeg$
^audio/wav$
^audio/.wma$
^audio/x-midi$
^audio/x-mp3$
^audio/x-mp4$
^audio/x-mpeg$
^audio/x-mpegurl$
^audio/x-ms-wma$
^audio/x-pn-realaudio$
^audio/x-pn-realaudio-plugin$
^audio/x-scpls$
^audio/x-wav$
^video/
^video/3gpp$
^video/avi$
^video/flash$
^video/flv$
^video/mp4$
^video/mpeg$
^video/mpeg4$
^video/ogg$
# etc, etc, etc
But these rules don't work. According to the analysis I have done, it seems that Squid is unable to block extensions when it is https encrypted traffic (http only)
PD: Additionally I tried with these rules that I found on the internet and neither:
acl video rep_header Content-Type video\/.*
acl audio rep_header Content-Type audio\/.*
http_reply_access deny video
http_reply_access deny audio
and:
acl mediapr urlpath_regex \.(avi|mp4|mov|m4v|mkv|flv|mpg|mpeg|wmv|rmvb|afx|asf|swf)(\?.*)?$
acl mediaprapp url_regex dvrplayer mediastream ^mms://
http_access deny mediapr mediaprapp
# Media Streams
acl media rep_mime_type ^application/x-shockwave-flash$
acl media rep_mime_type ^video/x-ms-asf$
acl media rep_mime_type ^application/vnd.ms.wms-hdr.asfv1$
acl media rep_mime_type ^application/x-mms-framed$
acl media rep_mime_type ^audio/x-pn-realaudio$
acl media rep_mime_type ^video/
acl media rep_mime_type ^video\/
acl media rep_mime_type ^application/x-shockwave-flash
acl media rep_mime_type ^application/vnd.ms.wms-hdr.asfv1
acl media rep_mime_type ^application/x-fcs
acl media rep_mime_type ^application/x-mms-framed
acl media rep_mime_type ^video/x-ms-asf
acl media rep_mime_type ^audio/mpeg
acl media rep_mime_type ^audio/x-scpls
acl media rep_mime_type ^video/x-flv
acl media rep_mime_type ^video/mpeg4
acl media rep_mime_type ms-hdr
acl media rep_mime_type x-fcs
acl media rep_mime_type mms
acl media rep_mime_type x-ms-asf
acl media rep_mime_type video/flv
acl media rep_mime_type video/x-flv
http_reply_access deny media
But nothing happen
Is there any way to block file mime_type file extensions in Squid in proxy-cache mode (not transparent - intercept) coming over https (without using SSL Bumping)?. thanks
PD: If this definitely has to be done with SSL Bump, then I can't. And I wonder if there is another alternative or another program (like a ipset, fail2ban, iptables without string rules because they are unreliable, etc.)?
SSL Bump to set filters on Squid HTTPS content
To set ACL's on HTTPS content, you will need to configure SSL Bump in Squid and import a cert that you generate into your browser and/or OS. Firefox has its own certificate store. Other browsers may use the certificate stores on the OS.
Example from my squid proxy, including comments on how to generate the cert. The NoBump.txt file should contain domains that you do not want to man-in-the-middle, such as banks, some google sub-domains, paypal and anyone else that uses public key pinning.
This is just an example. It would be best to read up on these options and different methods of accomplishing this on Squid's website, as this will change with newer versions of Squid and may vary depending on the version of Squid you are using. Especially pay attention to host_verify_strict as you may want that on depending on what sites you plan to access through this proxy. You will have to add the cert you generated from the comments and import into your cert store of your browser and/or OS.