<?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>Christian Schenk&#187; hardening</title>
	<atom:link href="http://www.christianschenk.org/blog/tag/hardening/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.christianschenk.org</link>
	<description>Writing about my experiences with technology and all different kinds of projects and experiments</description>
	<lastBuildDate>Sun, 04 Dec 2011 23:43:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Tuning and hardening Squid</title>
		<link>http://www.christianschenk.org/blog/tuning-and-hardening-squid/</link>
		<comments>http://www.christianschenk.org/blog/tuning-and-hardening-squid/#comments</comments>
		<pubDate>Fri, 26 Jan 2007 11:30:00 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[hardening]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[tuning]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/tuning-and-hardening-squid/</guid>
		<description><![CDATA[Here I collected some ideas about tuning and hardening Squid]]></description>
			<content:encoded><![CDATA[<p>Tuning and hardening <a title="Squid Web Proxy Cache" href="http://www.squid-cache.org/">Squid</a> will be the topic of this post, where tuning means making it a little bit faster and hardening means less vulnerable to malicious use. The default installation of Squid on a Debian box has a lot of features enabled which most likely aren&#8217;t used: we want to turn these off. Then there might be situations where you probably want to use Squid but don&#8217;t want it to function as a cache: we&#8217;ll investigate this too.</p>
<p><span id="more-9"></span></p>
<p>This post is geared towards my <a title="Setting up a Linux router based on the WRAP" href="http://www.christianschenk.org/blog/setting-up-a-linux-router-based-on-the-wrap/">next post</a>: it&#8217;s about a tiny router which hasn&#8217;t got a great disk or plenty of RAM. So I&#8217;m not going to discuss the pros and cons of various filesystems, using a RAID or having enough filedescriptors. If you&#8217;d like to read about that go <a title="High Performance Web Caching With Squid " href="http://www.devshed.com/c/a/Administration/High-Performance-Web-Caching-With-Squid/">here</a>, <a title="Squid Proxy Web Cache Wiki" href="http://wiki.squid-cache.org/">here</a> or <a title="Squid Handbuch - german only" href="http://www.squid-handbuch.de/hb/">here</a>.</p>
<h2>Tuning</h2>
<p>Tuning Squid will speed things up a little bit. So without further ado lets first take a look a the directives for the <em>squid.conf</em>:</p>
<pre class="code">pipeline_prefetch on
shutdown_lifetime 1 second</pre>
<p>While <a title="Documentation for pipeline_prefetch option" href="http://www.visolve.com/squid/squid24s1/delaypool.php#pipeline_prefetch">pipeline_prefetch</a> will boost the performance of pipelined requests to closer match that of a non-proxied environment, the second directive <a title="Documentation for shutdown_lifetime" href="http://www.visolve.com/squid/squid24s1/timeouts.php#shutdown_lifetime">shutdown_lifetime</a> saves you a lot of time waiting for Squid to shut down. The latter comes in very handy if you&#8217;re tweaking Squid and need to restart it a lot.</p>
<p>Even though Squid is meant as a cache there are reasons running it without a cache, i.e. as a pure forwarding proxy: you might want to use it as a load balancer with some <a title="Using a parent proxy with Squid" href="http://www.christianschenk.org/blog/using-a-parent-proxy-with-squid/">parent proxies</a>, simply as a <a title="Transparent proxy with Squid" href="http://www.christianschenk.org/blog/transparent-proxy-with-squid/">transparent proxy</a> or you don&#8217;t have particularly <a title="Setting up a Linux router based on the WRAP" href="http://www.christianschenk.org/blog/setting-up-a-linux-router-based-on-the-wrap/">fast hardware</a>. There are two methods to circumvent caching:</p>
<ol>
<li>Deny caching for all connections:
<pre class="code">acl all src 0.0.0.0/0.0.0.0
no_cache deny all</pre>
<p>This way neither a request will be satisfied from the cache nor the reply will be cached. Note that the first line might already be in your configuration.</p>
</li>
<li>If you use a parent proxy you can specify the <a title="Documentation for proxy-only option" href="http://www.visolve.com/squid/squid24s1/glossary.php#proxy-only">proxy-only</a> option to prevent that retrieved data from the remote cache is stored locally. An example:
<pre class="code">cache_peer proxy.isp.com parent 8080 0 proxy-only</pre>
</li>
</ol>
<p>Finally you might want to turn off logging. On a Debian based system it&#8217;s sufficient to turn of <a title="Documentation for cache_access_log" href="http://www.visolve.com/squid/squid24s1/logfiles.php#cache_access_log">cache_access_log</a> and <a title="Documentation for cache_store_log" href="http://www.visolve.com/squid/squid24s1/logfiles.php#cache_store_log">cache_store_log</a>:</p>
<pre class="code">cache_access_log none
cache_store_log none</pre>
<h2>Hardening</h2>
<p>When talking about hardening I think about turning off features that aren&#8217;t used and restricting access to the proxy. Features that aren&#8217;t used might be <a title="Documentation for icp_port" href="http://www.visolve.com/squid/squid24s1/network.php#icp_port">ICP</a> and <a title="Documentation for htcp_port" href="http://www.visolve.com/squid/squid24s1/network.php#htcp_port">HTCP</a>: they are used to communicate with other caches in a hierarchy. In most cases we don&#8217;t need this:</p>
<pre class="code">
icp_port 0
htcp_port 0
icp_access deny all
htcp_access deny all
</pre>
<p>If you don&#8217;t wish to use <a title="Documentation for snmp_port" href="http://www.visolve.com/squid/squid24s1/miscellaneous.php#snmp_port">SNMP</a> we can disable this too. This is already the default for systems running Debian.</p>
<pre class="code">snmp_port 0
snmp_access deny all</pre>
<p>At last you definitely want to restrict access to your proxy: define an access control list (<a title="Documentation for acl" href="http://www.visolve.com/squid/squid24s1/access_controls.php#acl">acl</a>) and either allow or deny access with <a title="Documentation for http_access" href="http://www.visolve.com/squid/squid24s1/access_controls.php#http_access">http_access</a>. Lets say your LAN is 172.16.0.0/24 and 172.16.1.0/24. Then you would put the following into <em>squid.conf</em>:</p>
<pre class="code">acl LAN src 172.16.0.0/24 172.16.1.0/24
http_access allow LAN</pre>
<p>If somebody outside your network tries to access your proxy he&#8217;ll get an error message that he isn&#8217;t allowed to do so.</p>
<h2>Conclusion</h2>
<p>Of course, this post just outlined the tip of the iceberg. There&#8217;s so much more to explore when it comes to tuning and hardening. Some ideas might include evaluating your efforts &#8211; is the cache really faster now? &#8211; or looking at other points in your network regarding security like a firewall. Anyway, I hope you got an overview of all the possibilities.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/tuning-and-hardening-squid/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

