📜 ⬆️ ⬇️

"Transparent" Squid with access control



How to cook a squid, I think that I’m not the only one who was faced with the task of setting up Squid for access control for employees, but at the same time it should be “transparent. In other words, the configuration shown below satisfies three conditions:



I would like to clarify the last point, since the gateway is “transparent”, we cannot use domain authorization of users, for this reason, the distinction is chosen precisely by ip-addresses.

As a basic configuration, materials from the article “Transparent” Squid with HTTPS filtering resources without certificate substitution (x86) were used . Since the installation and configuration of components in this article are described in sufficient detail, I will skip this information.

The software I used to test the configuration:


So, the /etc/squid/squid.conf file :

acl localnet src 192.168.0.0/16 # RFC1918 possible internal network 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 Safe_ports port 901 # SWAT acl CONNECT method CONNECT #  acl  : ,      acl denied_urls url_regex "/etc/squid/denied_urls" acl allowed_urls url_regex "/etc/squid/allowed_urls" acl extended_access_group src "/etc/squid/extended_access_group" http_access deny !Safe_ports http_access deny CONNECT !SSL_ports http_access allow localhost manager http_access deny manager #  -    ,         #  https  . #    ,  https http_access allow localnet CONNECT #      http_access deny denied_urls #             #  http_access deny !extended_access_group !allowed_urls http_access allow localnet http_access allow localhost http_access deny all #            http_port 3130 http_port 3128 intercept https_port 3129 intercept ssl-bump options=ALL:NO_SSLv3:NO_SSLv2 connection-auth=off cert=/etc/squid/squidCA.pem always_direct allow all sslproxy_cert_error allow all sslproxy_flags DONT_VERIFY_PEER #   ssl acl allowed_urls_ssl ssl::server_name_regex "/etc/squid/allowed_urls" acl denied_urls_ssl ssl::server_name_regex "/etc/squid/denied_urls" acl step1 at_step SslBump1 ssl_bump peek step1 ssl_bump terminate denied_urls_ssl ssl_bump splice extended_access_group ssl_bump terminate !allowed_urls_ssl ssl_bump splice all sslcrtd_program /usr/lib/squid/ssl_crtd -s /var/lib/ssl_db -M 4MB #cache_dir ufs /var/cache/squid 100 16 256 coredump_dir /var/cache/squid 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 

Before running Squid, do not forget to create three files in / etc / squid / . denied_urls and allowed_urls of the form:

 geektimes.ru habrahabr.ru toster.ru windowsupdate.microsoft.com 

And extended_access_group of the form:

 192.168.1.5 # .. 192.168.1.87 # .. 192.168.1.108 # .. 

When accessing http on a banned site, it will issue a standard Squid stub, and via https - “ERR_SSL_PROTOCOL_ERROR”.

Thank you for reading the article.

Source: https://habr.com/ru/post/314718/


All Articles