<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>SNI on devcodenote.gitlab.io</title><link>https://devcodenote.gitlab.io/categories/sni/</link><description>Recent content in SNI on devcodenote.gitlab.io</description><generator>Hugo -- gohugo.io</generator><language>es-es</language><lastBuildDate>Sat, 07 Jun 2025 10:30:00 -0600</lastBuildDate><atom:link href="https://devcodenote.gitlab.io/categories/sni/index.xml" rel="self" type="application/rss+xml"/><item><title>Squid proxy 6.0 for Https Filter [Ubuntu 24.04 LTS] [Transparent Proxy]</title><link>https://devcodenote.gitlab.io/posts/squid-proxy-6.0-for-https-filter-ubuntu-24.04-lts-transparent-proxy/</link><pubDate>Sat, 07 Jun 2025 10:30:00 -0600</pubDate><guid>https://devcodenote.gitlab.io/posts/squid-proxy-6.0-for-https-filter-ubuntu-24.04-lts-transparent-proxy/</guid><description>&lt;img src="https://devcodenote.gitlab.io/images/8eae27349b3b1381cd930ef923d1d0cea41e9adfd9d4338ace34a7621045d44926cadff03f5a9dfe7edc0143a14f362eb646ba7c50183987d09e8110ab6770ae.png" alt="Featured image of post Squid proxy 6.0 for Https Filter [Ubuntu 24.04 LTS] [Transparent Proxy] " />&lt;h2 id="squid-proxy-is-a-great-tool-that-allows-us-to-do-multiple-things-one-of-them-is-to-function-as-a-forward-proxy-and-with-the-use-of-acls-we-can-filter-sites-using-the-sni">Squid Proxy is a great tool that allows us to do multiple things; one of them is to function as a forward proxy, and with the use of ACLs, we can filter sites using the SNI.
&lt;/h2>&lt;h2 id="installation">installation
&lt;/h2>&lt;p>Squid proxy is installed via apt-get. The squid-openssl version is of interest to us since it contains ssl-bump. If our distribution does not include squid-openssl, it must be installed manually.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo apt-get install squid-openssl
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="https://devcodenote.gitlab.io/images/9034cefa695d9cf73265449df6f2ba05025a2268660c542a44fb1107d1ef4b2610cde1591a62ded00bde3f9d8d2aa3d307087828e21ae3a8b9cfe05567708983.png"
loading="lazy"
alt="Name"
>&lt;/p>
&lt;p>We generate the SSL certificates, remember they must be in /etc/squid/ssl; otherwise, Squid will not trust the certificate.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>cd /etc/ssl/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo openssl ecparam -name prime256v1 -genkey -noout -out sslsquid.key
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo openssl req -x509 -days &lt;span style="color:#ae81ff">365&lt;/span> -nodes -key sslsquid.key -out sslsquid.crt
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>For Squid Proxy 6.0, it gives the following error if it’s not installed in /etc/ssl/.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>× squid.service - Squid Web Proxy Server
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Loaded: loaded &lt;span style="color:#f92672">(&lt;/span>/usr/lib/systemd/system/squid.service; enabled; preset: enabled&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Active: failed &lt;span style="color:#f92672">(&lt;/span>Result: exit-code&lt;span style="color:#f92672">)&lt;/span> since Fri 2024-06-07 05:48:16 CST; 4s ago
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Duration: 25min 6.288s
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Docs: man:squid&lt;span style="color:#f92672">(&lt;/span>8&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> Process: &lt;span style="color:#ae81ff">4522&lt;/span> ExecStartPre&lt;span style="color:#f92672">=&lt;/span>/usr/sbin/squid --foreground -z &lt;span style="color:#f92672">(&lt;/span>code&lt;span style="color:#f92672">=&lt;/span>exited, status&lt;span style="color:#f92672">=&lt;/span>1/FAILURE&lt;span style="color:#f92672">)&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> CPU: 54ms
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform squid&lt;span style="color:#f92672">[&lt;/span>4522&lt;span style="color:#f92672">]&lt;/span>: 2024/06/07 05:48:16| Finished. Wrote &lt;span style="color:#ae81ff">0&lt;/span> entries.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform squid&lt;span style="color:#f92672">[&lt;/span>4522&lt;span style="color:#f92672">]&lt;/span>: 2024/06/07 05:48:16| Took 0.00 seconds &lt;span style="color:#f92672">(&lt;/span> 0.00 entries/sec&lt;span style="color:#f92672">)&lt;/span>.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform squid&lt;span style="color:#f92672">[&lt;/span>4522&lt;span style="color:#f92672">]&lt;/span>: 2024/06/07 05:48:16| FATAL: No valid signing certificate configured &lt;span style="color:#66d9ef">for&lt;/span> HTTPS_port &lt;span style="color:#f92672">[&lt;/span>::&lt;span style="color:#f92672">]&lt;/span>:3135
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform squid&lt;span style="color:#f92672">[&lt;/span>4522&lt;span style="color:#f92672">]&lt;/span>: 2024/06/07 05:48:16| Squid Cache &lt;span style="color:#f92672">(&lt;/span>Version 6.6&lt;span style="color:#f92672">)&lt;/span>: Terminated abnormally.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform squid&lt;span style="color:#f92672">[&lt;/span>4522&lt;span style="color:#f92672">]&lt;/span>: CPU Usage: 0.060 seconds &lt;span style="color:#f92672">=&lt;/span> 0.047 user + 0.013 sys
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform squid&lt;span style="color:#f92672">[&lt;/span>4522&lt;span style="color:#f92672">]&lt;/span>: Maximum Resident Size: &lt;span style="color:#ae81ff">74752&lt;/span> KB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform squid&lt;span style="color:#f92672">[&lt;/span>4522&lt;span style="color:#f92672">]&lt;/span>: Page faults with physical i/o: &lt;span style="color:#ae81ff">0&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform systemd&lt;span style="color:#f92672">[&lt;/span>1&lt;span style="color:#f92672">]&lt;/span>: squid.service: Control process exited, code&lt;span style="color:#f92672">=&lt;/span>exited, status&lt;span style="color:#f92672">=&lt;/span>1/FAILURE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform systemd&lt;span style="color:#f92672">[&lt;/span>1&lt;span style="color:#f92672">]&lt;/span>: squid.service: Failed with result &lt;span style="color:#e6db74">&amp;#39;exit-code&amp;#39;&lt;/span>.
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>Jun &lt;span style="color:#ae81ff">07&lt;/span> 05:48:16 toor-VMware-Virtual-Platform systemd&lt;span style="color:#f92672">[&lt;/span>1&lt;span style="color:#f92672">]&lt;/span>: Failed to start squid.service - Squid Web Proxy Server.
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>To configure Squid, we do the following:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span> cd /etc/squid/
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sudo nano squid.conf
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>To configure Squid, we do the following:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>http_port &lt;span style="color:#ae81ff">3131&lt;/span> intercept
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>https_port &lt;span style="color:#ae81ff">3135&lt;/span> intercept ssl-bump tls-cert&lt;span style="color:#f92672">=&lt;/span>/etc/ssl/sslsquid.crt tls-key&lt;span style="color:#f92672">=&lt;/span>/etc/ssl/sslsquid.key generate-host-certificates&lt;span style="color:#f92672">=&lt;/span>on dynamic_cert_mem_cache_size&lt;span style="color:#f92672">=&lt;/span>16MB
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>http_access allow localnet
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="https://devcodenote.gitlab.io/images/3929c81e35a5719f6884afb94c6b337e6e0ef3f7aeed5fb0221f7343a9518fd80bb5963bf063c1dc565766d63f487d5f496373386e72b2022804c916385328bf.png"
loading="lazy"
alt="Name"
>&lt;/p>
&lt;p>Uncomment the following line.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>&lt;span style="color:#75715e">#Default:&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span> sslcrtd_program /usr/lib/squid/security_file_certgen -s /var/spool/squid/ssl_db -M 4MB
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>&lt;img src="https://devcodenote.gitlab.io/images/b69d71a0d29f37d5f070dcb09c0093615969d27c1aa02be7abe62e7ff5cb774efb1ff8e50975ffd64ef13f2d8bf8acf9c0f2ff34e40416805def1bcc3e39573f.png"
loading="lazy"
alt="Name"
>&lt;/p>
&lt;p>We have to configure iptables so that the traffic goes through squid proxy&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo iptables -t nat -I PREROUTING -p tcp -m tcp --dport &lt;span style="color:#ae81ff">443&lt;/span> -j REDIRECT --to-ports &lt;span style="color:#ae81ff">3135&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo iptables -t nat -I PREROUTING -p tcp -m tcp --dport &lt;span style="color:#ae81ff">80&lt;/span> -j REDIRECT --to-ports &lt;span style="color:#ae81ff">3131&lt;/span>
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo iptables -t nat -A POSTROUTING -o ens33 -j MASQUERADE
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo sysctl -w net.ipv4.ip_forward&lt;span style="color:#f92672">=&lt;/span>&lt;span style="color:#ae81ff">1&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="access-controls">Access Controls
&lt;/h2>&lt;p>We create a file where the domains to be blocked will be&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span> sudo mkdir /blockwebsites
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>cd /blockwebsites
&lt;/span>&lt;/span>&lt;span style="display:flex;">&lt;span>sudo nano list1
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We add example.com as an example.&lt;/p>
&lt;p>&lt;code>example.com&lt;/code>&lt;/p>
&lt;h2 id="block-web-site-via-sni-server-name-indication">Block web site via SNI (Server Name Indication)
&lt;/h2>&lt;div class="highlight">&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;">&lt;code class="language-bash" data-lang="bash">&lt;span style="display:flex;">&lt;span>sudo nano /etc/squid/squid.conf
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>We add the following at the end of the configuration.&lt;/p>
&lt;pre tabindex="0">&lt;code>acl monitoredSites ssl::server_name &amp;#34;/blockwebsites/list1&amp;#34;
ssl_bump terminate monitoredSites
ssl_bump peek all
ssl_bump splice all
&lt;/code>&lt;/pre>&lt;p>In this case we do not want to interfere with the original certificate we use
ssl_bump peek all
ssl_bump splice all&lt;/p>
&lt;p>&lt;a class="link" href="https://wiki.squid-cache.org/Features/SslPeekAndSplice" target="_blank" rel="noopener"
>https://wiki.squid-cache.org/Features/SslPeekAndSplice&lt;/a>&lt;/p>
&lt;p>&lt;img src="https://devcodenote.gitlab.io/images/8eae27349b3b1381cd930ef923d1d0cea41e9adfd9d4338ace34a7621045d44926cadff03f5a9dfe7edc0143a14f362eb646ba7c50183987d09e8110ab6770ae.png"
loading="lazy"
alt="Name"
>&lt;/p>
&lt;p>&lt;img src="https://devcodenote.gitlab.io/images/d7f81f61121521e249fb31d971fe372b7f84421cdb298263324d49d21ab00a9d32e14769101222af4cca06a21b134474a1c9155df279f85da6aab82a2b498b91.png"
loading="lazy"
alt="Name"
>&lt;/p>
&lt;p>The website is working without installing any certificate on the client&lt;/p>
&lt;p>&lt;img src="https://devcodenote.gitlab.io/images/edf1786ab6b3bb51266cf81f277a1e68f584652482d2f83d745e3735ce984744343a21f0516d1081e80c263bac1d44fcb491452a3dd89a1e392607a741022d31.png"
loading="lazy"
alt="Name"
>&lt;/p>
&lt;hr>
&lt;h1 id="block-quic-using-the-firewall-policy">Block QUIC using the firewall policy.
&lt;/h1>&lt;p>Squid Proxy does not support QUIC, so we have to disable it.&lt;/p>
&lt;pre tabindex="0">&lt;code>sudo iptables -I FORWARD -p udp --dport 443 -j REJECT --reject-with icmp-port-unreachable
&lt;/code>&lt;/pre></description></item></channel></rss>