<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Squid &#8211; My Shitty Code</title>
	<atom:link href="https://myshittycode.com/tag/squid/feed/" rel="self" type="application/rss+xml" />
	<link>https://myshittycode.com</link>
	<description>Embracing the Messiness in Search of Epic Solutions</description>
	<lastBuildDate>Fri, 06 Jan 2023 04:03:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://myshittycode.com/wp-content/uploads/2022/04/cropped-icon-32x32.png</url>
	<title>Squid &#8211; My Shitty Code</title>
	<link>https://myshittycode.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">205304208</site>	<item>
		<title>Squid: Configuring Whitelisted URLs</title>
		<link>https://myshittycode.com/2021/04/21/squid-configuring-whitelisted-urls/</link>
					<comments>https://myshittycode.com/2021/04/21/squid-configuring-whitelisted-urls/#comments</comments>
		
		<dc:creator><![CDATA[Shitty Author]]></dc:creator>
		<pubDate>Thu, 22 Apr 2021 03:01:40 +0000</pubDate>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[Squid]]></category>
		<guid isPermaLink="false">https://myshittycode.com/?p=1201</guid>

					<description><![CDATA[<p>PROBLEM To configure a proxy server that only allows whitelisted URLs through. SOLUTION Install Squid&#8230; in this case, on Ubuntu. Ensure the service is running. Create a file ( /etc/squid/whitelist.txt ) containing the whitelisted URLs. In this example, only one URL is whitelisted. To simplify the configuration, backup /etc/squid/squid.conf and create the same file with [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://myshittycode.com/2021/04/21/squid-configuring-whitelisted-urls/">Squid: Configuring Whitelisted URLs</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">PROBLEM</h2>



<p>To configure a proxy server that only allows whitelisted URLs through.</p>



<h2 class="wp-block-heading">SOLUTION</h2>



<p>Install Squid&#8230; in this case, on Ubuntu.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo apt install -y squid
</pre></div>


<p>Ensure the service is running.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
my@shittycode:/etc/squid$ sudo systemctl status squid
● squid.service - Squid Web Proxy Server
Loaded: loaded (/lib/systemd/system/squid.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2021-04-21 17:20:54 CDT; 3min 3s ago
Docs: man:squid(8)
Process: 9008 ExecStartPre=/usr/sbin/squid --foreground -z (code=exited, status=0/SUCCESS)
Process: 9012 ExecStart=/usr/sbin/squid -sYC (code=exited, status=0/SUCCESS)
Main PID: 9013 (squid)
Tasks: 4 (limit: 44379)
Memory: 16.1M
CGroup: /system.slice/squid.service
├─9013 /usr/sbin/squid -sYC
├─9015 (squid-1) --kid squid-1 -sYC
├─9016 (logfile-daemon) /var/log/squid/access.log
└─9017 (pinger)

Apr 21 17:20:54 shittycode squid&#x5B;9015]: Max Swap size: 0 KB
Apr 21 17:20:54 shittycode squid&#x5B;9015]: Using Least Load store dir selection
Apr 21 17:20:54 shittycode squid&#x5B;9015]: Set Current Directory to /var/spool/squid
Apr 21 17:20:54 shittycode squid&#x5B;9015]: Finished loading MIME types and icons.
Apr 21 17:20:54 shittycode squid&#x5B;9015]: HTCP Disabled.
Apr 21 17:20:54 shittycode squid&#x5B;9015]: Pinger socket opened on FD 14
Apr 21 17:20:54 shittycode squid&#x5B;9015]: Squid plugin modules loaded: 0
Apr 21 17:20:54 shittycode squid&#x5B;9015]: Adaptation support is off.
Apr 21 17:20:54 shittycode squid&#x5B;9015]: Accepting HTTP Socket connections at local=&#x5B;::]:3128 remote=&#x5B;::] FD 12 flags=9
Apr 21 17:20:55 shittycode squid&#x5B;9015]: storeLateRelease: released 0 objects
</pre></div>


<p>Create a file ( <code>/etc/squid/whitelist.txt</code> ) containing the whitelisted URLs. In this example, only one URL is whitelisted.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
my@shittycode:/etc/squid$ cat whitelist.txt
www.google.com
</pre></div>


<p>To simplify the configuration, backup <code>/etc/squid/squid.conf</code> and create the same file with these minimal configurations.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
my@shittycode:/etc/squid$ cat squid.conf

# An ACL named &#039;whitelist&#039;
acl whitelist dstdomain &#039;/etc/squid/whitelist.txt&#039;

# Allow whitelisted URLs through
http_access allow whitelist

# Block the rest
http_access deny all

# Default port
http_port 3128
</pre></div>


<p>Restart the service to pick up the change.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo systemctl restart squid
</pre></div>


<p>To test the configuration, when hitting a non-whitelisted URL, it should return 403.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
my@shittycode:/etc/squid$ curl -x localhost:3128 -I -L yahoo.com
HTTP/1.1 403 Forbidden
Server: squid/4.10
Mime-Version: 1.0
Date: Wed, 21 Apr 2021 22:22:02 GMT
Content-Type: text/html;charset=utf-8
Content-Length: 3507
X-Squid-Error: ERR_ACCESS_DENIED 0
Vary: Accept-Language
Content-Language: en
X-Cache: MISS from shittycode
X-Cache-Lookup: NONE from shittycode:3128
Via: 1.1 shittycode (squid/4.10)
Connection: keep-alive
</pre></div>


<p>When hitting a whitelisted URL, it should return 200.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
my@shittycode:/etc/squid$ curl -x localhost:3128 -I -L www.google.com
HTTP/1.1 200 OK
Content-Type: text/html; charset=ISO-8859-1
P3P: CP=&quot;This is not a P3P policy! See g.co/p3phelp for more info.&quot;
Date: Wed, 21 Apr 2021 22:21:03 GMT
Server: gws
X-XSS-Protection: 0
X-Frame-Options: SAMEORIGIN
Expires: Wed, 21 Apr 2021 22:21:03 GMT
Cache-Control: private
Set-Cookie: 1P_JAR=2021-04-21-22; expires=Fri, 21-May-2021 22:21:03 GMT; path=/; domain=.google.com; Secure
Set-Cookie: NID=214=AAK1Z6cV4cXlOGLIdHrKhiyzW2iBKpkN5-3OXvVrxEGrw-VekbvM1uFMMUAGubhAciT8NcyCVto2fpDPHJXRBECcqJRFTsUDNb3WBUNIgvK0zWpyxz8bl1aSqB22nQhf2fEwfDM9nAkVZyQG8rst054qOfAHO9kDvkrZRWn9HyM; expires=Thu, 21-Oct-2021 22:21:03 GMT; path=/; domain=.google.com; HttpOnly
X-Cache: MISS from shittycode
X-Cache-Lookup: MISS from shittycode:3128
Via: 1.1 shittycode (squid/4.10)
Connection: keep-alive
</pre></div><p>The post <a rel="nofollow" href="https://myshittycode.com/2021/04/21/squid-configuring-whitelisted-urls/">Squid: Configuring Whitelisted URLs</a> appeared first on <a rel="nofollow" href="https://myshittycode.com">My Shitty Code</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://myshittycode.com/2021/04/21/squid-configuring-whitelisted-urls/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1201</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Lazy Loading (feed)
Database Caching using Disk

Served from: myshittycode.com @ 2026-02-20 10:23:01 by W3 Total Cache
-->