<?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; proxy</title>
	<atom:link href="http://www.christianschenk.org/blog/tag/proxy/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, 29 Aug 2010 09:08:16 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Building a simple proxy checker tool</title>
		<link>http://www.christianschenk.org/blog/building-simple-proxy-checker-tool/</link>
		<comments>http://www.christianschenk.org/blog/building-simple-proxy-checker-tool/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 06:45:41 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[checker]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[tool]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/?p=713</guid>
		<description><![CDATA[In case you&#8217;re trying to change the configuration of your proxy server you might want to check what appears in the logs of a web server returning data to your proxy. Maybe you want to suppress certain HTTP header fields or make sure that the browser&#8217;s user agent is forged correctly. 
This post discusses a [...]]]></description>
			<content:encoded><![CDATA[<p>In case you&#8217;re trying to change the configuration of your proxy server you might want to check what appears in the logs of a web server returning data to your proxy. Maybe you want to suppress certain HTTP header fields or make sure that the browser&#8217;s user agent is forged correctly. </p>
<p>This post discusses a PHP script which tries to display helpful information from the web server&#8217;s perspective. Although it may not be complete you can easily extend it to suit your needs.</p>
<p><span id="more-713"></span></p>
<h2>The tool</h2>
<p>All we need to do is to upload <a href="http://data.christianschenk.org/building-simple-proxy-checker-tool/proxy-tool.php.zip">this</a> script to a web server and access it through our proxy. The output shows us the information a web server may store in his log files, i.e. things like our IP address, the referrer, the browser&#8217;s user agent and proxy related fields like <code>Via</code> or <code>Forwarded-For</code>.</p>
<p>The code needed to implement this in PHP is pretty easy: just have a look at <code>$_SERVER</code> and you&#8217;ll find a lot of interesting information. In case you&#8217;re missing something have a look at PHP&#8217;s <a href="http://www.php.net/manual/en/reserved.variables.php">predefined variables</a>. Maybe you want to play around with cookies, check out <code>$_COOKIE</code> if you would like to display information about cookies.</p>
<p>Why do we need another proxy checker, there are plenty of websites doing this kind of stuff, you may ask. I think that depends on two factors: speed and reliability. Obviously, uploading the script to your web server at home and sending requests to this machine will be a lot faster than any web server on the internet. Second, you need reliable information, i.e. again it&#8217;s easier to trust your own web server and PHP script than some site on the net.</p>
<h2>Conclusion</h2>
<p>Using PHP it&#8217;s easy to bootstrap your own proxy checker tool. Although the script presented in this posts is really simple, it helps us to get the relevant information quick. Repeatedly requesting the script and tweaking the configuration of your proxy should help you to get the desired results.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/building-simple-proxy-checker-tool/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caching with dynamic proxy classes</title>
		<link>http://www.christianschenk.org/blog/caching-with-dynamic-proxy-classes/</link>
		<comments>http://www.christianschenk.org/blog/caching-with-dynamic-proxy-classes/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 08:25:10 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/caching-with-dynamic-proxy-classes/</guid>
		<description><![CDATA[Read about a solution to cache objects with a dynamic proxy class]]></description>
			<content:encoded><![CDATA[<p>In my <a title="Caching with AspectJ" href="http://www.christianschenk.org/blog/caching-with-aspectj/">last post</a> I used AspectJ to implement a cache that stored the returned result of methods with a special annotation (<code>@Cachable</code>). If you can&#8217;t use AspectJ you may want to use a dynamic proxy class: in this post I&#8217;ll present a solution for this.</p>
<p>You can download the Eclipse project as a <a href="http://data.christianschenk.org/caching-with-dynamic-proxy-classes/CachingWithProxyInstances-1.0.tar.gz">tar</a> or <a href="http://data.christianschenk.org/caching-with-dynamic-proxy-classes/CachingWithProxyInstances-1.0.zip">zip</a> file or view the code online <a href="http://data.christianschenk.org/caching-with-dynamic-proxy-classes/xref/">here</a>.</p>
<p><span id="more-82"></span></p>
<h2>Implementation</h2>
<p>If you don&#8217;t know how <a title="Dynamic Proxy Classes" href="http://java.sun.com/j2se/1.3/docs/guide/reflection/proxy.html">dynamic proxy classes</a> work here&#8217;s a short overview. Let&#8217;s say you want to do some extra work if the methods <code>foo</code> and <code>bar</code> from the class <code>Tee</code> are called. You would extract the methods into an interface and let <code>Tee</code> implement this interface.</p>
<p>Next, you&#8217;d implement a factory that produces a proxy instance for <code>Tee</code> with a custom <code>InvocationHandler</code>. This handler would have a look at the method&#8217;s name and check whether it&#8217;s <code>foo</code> or <code>bar</code>: you can now implement any extra actions in this handler.</p>
<p>You can also examine the annotations of the invoked method and that&#8217;s what I did: if the method has got the <code>@Cachable</code> annotation we&#8217;ll utilize a cache. But how do we know whether we can safely return an object from the cache?</p>
<h3>Constructing a unique method identifier</h3>
<p>This is crucial since we don&#8217;t want to return the same result from the cache if the method was called with different parameters. So we&#8217;ll have to add the values of the parameters to a identifier like so:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #0000ff;">&quot;package-name&quot;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;class-name&quot;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;method-name&quot;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;param1-param2-[...]&quot;</span></pre></div></div>

<p>This way we&#8217;ll create a unique entry in the cache for different method calls.</p>
<h2>How to</h2>
<p>All we have to do is to add <code>@Cachable</code> to some methods:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> Foo <span style="color: #009900;">&#123;</span>
  @Cachable
  <span style="color: #000000; font-weight: bold;">public</span> SomeObject foo<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> param<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  @Cachable
  <span style="color: #000000; font-weight: bold;">public</span> AnotherObject bar<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> param1, <span style="color: #000066; font-weight: bold;">long</span> param2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Once we&#8217;ve done that we can use the factory to produce a new proxy instance with our custom <code>InvocationHandler</code>. The handler will use the cache, i.e. the method calls will return faster.</p>
<h2>Conclusion</h2>
<p>In this post I presented a simple solution for a cache that may speed up method calls. Although I recommend using AspectJ for this kind of job you can use dynamic proxy instances if your environment (in most cases read: your project leader) doesn&#8217;t permit you to use AspectJ.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/caching-with-dynamic-proxy-classes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Enhancing your privacy further with Squid and Tor</title>
		<link>http://www.christianschenk.org/blog/enhancing-your-privacy-further-with-squid-and-tor/</link>
		<comments>http://www.christianschenk.org/blog/enhancing-your-privacy-further-with-squid-and-tor/#comments</comments>
		<pubDate>Mon, 29 Jan 2007 05:45:09 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[tor]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/enhancing-your-privacy-further-with-squid-and-tor/</guid>
		<description><![CDATA[Shows how to enhance your privacy on the web with Squid and Tor]]></description>
			<content:encoded><![CDATA[<p>In my <a title="Enhancing your privacy using Squid and Privoxy" href="http://www.christianschenk.org/blog/enhancing-your-privacy-using-squid-and-privoxy/">last post</a> I described how to use <a title="Squid Web Proxy Cache" href="http://www.squid-cache.org/">Squid</a> and <a title="Privoxy - Home Page" href="http://www.privoxy.org/">Privoxy</a> to enhance your privacy while surfing the internet. We want to push this a little bit further by adding onion routing with <a title="Tor Homepage" href="http://tor.eff.org/">Tor</a>. If you heard about Tor but don&#8217;t really know how it works, I suggest reading the <a href="http://tor.eff.org/overview.html">Tor overview</a> first.</p>
<p><span id="more-15"></span></p>
<p>Based on my last post we&#8217;ll build an even longer chain of proxies: a request from our browser is sent to Squid and handed to Privoxy which in turn will hand it to Tor. Then the request makes its way through the onion router network and finally reaches the web server. The performance of the onion router network may be bad and sometimes worse. Unless you really want to take care of your anonymity (who doesn&#8217;t <img src='http://www.christianschenk.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ) I suggest not using Tor. It&#8217;s not one of those things you just do for fun because it doesn&#8217;t hurt. If you&#8217;re paranoid enough and aren&#8217;t scared off to wait at best thirty seconds for one website to load then you should read on.</p>
<h2>Configuring Tor</h2>
<p>If you&#8217;re using a Debian system and aren&#8217;t on the unstable branch, you have to put the following into <em>/etc/apt/sources.list</em>:</p>
<pre class="code">deb http://ftp.debian.org/debian unstable main contrib non-free</pre>
<p>Depending on your <a title="Debian-Releases" href="http://www.debian.org/releases/">release</a> you have to put this line into <em>/etc/apt/apt.conf</em> to prevent future updates coming from the unstable branch:</p>
<pre class="code">APT::Default-Release "testing";</pre>
<p>After that you can use <a title="aptitude package page" href="http://packages.debian.org/aptitude">aptitude</a> to install Tor:</p>
<pre class="code">aptitude update
aptitude install tor socat</pre>
<p>Finally we need to tell Squid to forward requests to Privoxy, i.e. use it as a parent proxy. If you haven&#8217;t already done so add the following to <em>squid.conf</em>:</p>
<pre class="code">cache_peer localhost parent 8118 7 no-digest no-query
never_direct allow all</pre>
<p>And Privoxy should forward to Tor. Put this into Privoxy&#8217;s <em>config</em> file:</p>
<pre class="code">forward-socks4a / 127.0.0.1:9050 .</pre>
<p>That&#8217;s it. After starting Squid, Privoxy and Tor you&#8217;re ready to retrieve websites.</p>
<h2>Torify everything</h2>
<p>The problem with this setup is that it leaks DNS requests. I recommend reading the <a title="Torifying software HOWTO" href="http://wiki.noreply.org/noreply/TheOnionRouter/TorifyHOWTO">Torify Howto</a> or the section <em>Anonymizing various applications</em> on <a title="Uwe Hermann - Anonymous communication with Tor" href="http://www.hermann-uwe.de/blog/howto-anonymous-communication-with-tor-some-hints-and-some-pitfalls" rel="nofollow">Uwe Hermanns blog</a>, if you&#8217;d like to get rid of this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/enhancing-your-privacy-further-with-squid-and-tor/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enhancing your privacy using Squid and Privoxy</title>
		<link>http://www.christianschenk.org/blog/enhancing-your-privacy-using-squid-and-privoxy/</link>
		<comments>http://www.christianschenk.org/blog/enhancing-your-privacy-using-squid-and-privoxy/#comments</comments>
		<pubDate>Sat, 27 Jan 2007 12:00:39 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[privacy]]></category>
		<category><![CDATA[privoxy]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/enhancing-your-privacy-using-squid-and-privoxy/</guid>
		<description><![CDATA[Shows how to enhance your privacy on the web with Squid and Privoxy]]></description>
			<content:encoded><![CDATA[<p>If you would like to surf the internet anonymously I&#8217;ll show you how to use <a title="Squid Web Proxy Cache" href="http://www.squid-cache.org/">Squid</a> and <a title="Privoxy - Home Page" href="http://www.privoxy.org/">Privoxy</a> for this purpose. First we&#8217;ll configure Squid to filter some <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header fields. After this, web servers will most likely think that we aren&#8217;t requesting content through a proxy but rather directly with our browser. We will see that we can&#8217;t manipulate all HTTP header fields without running into problems: Privoxy will help us here.</p>
<p><span id="more-10"></span></p>
<p>You can test your setup with <a href="http://www.proxyjudge.com/" rel="nofollow">ProxyJudge</a> or <a href="http://checker.samair.ru/" rel="nofollow">SamAir</a>; there are a lot of <a title="Google Search" href="http://www.google.com/search?q=proxy+anonymous+check">other tools</a> which provide this functionality. While SamAir just checks some HTTP header fields, ProxyJudge will do a more comprehensive check. It will calculate your <em>level of anonymity</em>: it ranges from 1 to 5 where level 1 is excellent and 5 bad. If you&#8217;re already using a proxy, your level of anonymity might be bad: go check it right now so you can compare the results later.</p>
<h2>Configuring Squid</h2>
<p>If you don&#8217;t want to use Privoxy you can still set some options in your <em>squid.conf</em>, which will get you up on level 1 or 2 at ProxyJudge. Here they are:</p>
<pre class="code">via off
forwarded_for off

header_access From deny all
header_access Server deny all
header_access WWW-Authenticate deny all
header_access Link deny all
header_access Cache-Control deny all
header_access Proxy-Connection deny all
header_access X-Cache deny all
header_access X-Cache-Lookup deny all
header_access Via deny all
header_access Forwarded-For deny all
header_access X-Forwarded-For deny all
header_access Pragma deny all
header_access Keep-Alive deny all</pre>
<p>These directives control some HTTP header fields, which are set by Squid or another proxy if your Squid is part of a hierarchy of proxies. The <a title="RFC for HTTP - see section 14.45" href="http://www.ietf.org/rfc/rfc2616.txt">Via</a> and Forwarded-For fields are set to indicate that this request was forwarded by a proxy. This is something we don&#8217;t want, because this would leak the information that we&#8217;re using a proxy. Due to this reason the bunch of <em>header_access</em> lines deny some other fields too.</p>
<p>After you&#8217;ve done this you should have a rating of 1 or 2: you only get a 1 if you haven&#8217;t got reverse DNS enabled for your IP. More often than not this is something you can&#8217;t control but your <abbr title="Internet Service Provider">ISP</abbr>. If you don&#8217;t want every web server to know your current IP you can setup Squid to use <a title="Using a parent proxy with Squid" href="http://www.christianschenk.org/blog/using-a-parent-proxy-with-squid/">another proxy</a> as parent, e.g. a proxy provided by your ISP. Be aware that this might result in a bad rating, because the parent proxy might set the mentioned HTTP header fields and obviously you can&#8217;t change that.</p>
<p>So far this setup is highly effective, but I still recommend enabling Privoxy.</p>
<h2>Configuring Privoxy</h2>
<p>The advanced filtering capabilities of Privoxy can be used to mangle all different kind of things: web page content, cookies and disturbing internet junk like ads, pop-ups and banners. It is also possible to change some HTTP header fields. This is crucial: if we would have added these lines:</p>
<pre class="code">header_access Referer deny all
header_access User-Agent deny all</pre>
<p>to the <em>squid.conf</em>, some websites wouldn&#8217;t function correctly, because they require these fields. If these fields aren&#8217;t set, parts of a website might not be displayed or you&#8217;re denied access completely. This is were Privoxy comes into play: you can set these two fields to whatever you want or let Privoxy decide this dynamically at runtime, e.g. it fakes the referrer to point to the requested website instead of revealing the page you really came from.</p>
<p>Now install Privoxy and change the following in its <em>config</em> file:</p>
<pre class="code">#debug 1
forward  /     proxy.isp.com:8080
forward  :443  .</pre>
<p>The first line needs to be commented out or Privoxy would write every request to its logfile. The second and third line say that every request should be passed to this parent proxy and every HTTPS connection should be established directly with the foreign web server. These <em>forward</em> lines are read from top to bottom: the <strong>last</strong> line that matches will be used. If you don&#8217;t want to use a parent proxy at all you could just write:</p>
<pre class="code">forward  /     .</pre>
<p>which says that requests should be made directly with the web servers.</p>
<p>Next we need to make some changes to the file named <em>default.action</em>. There is an action which matches all URLs and the following lines can be defined for it:</p>
<pre class="code">+hide-referrer{forge}
+hide-user-agent{Mozilla/5.0}</pre>
<p>While the first line defines thats the referrer should be forged to match the current website the second line sets the User-Agent field no matter what browser we&#8217;re using behind our proxy. You probably want to set the User-Agent to something different, e.g. if you&#8217;re using IE. I haven&#8217;t run into problems with this settings yet, though I&#8217;m using <a title="Mozilla Firefox Homepage" href="http://www.mozilla.com/firefox/">Firefox</a> and <a title="Apple - Mac OS X - Safari" href="http://www.apple.com/de/macosx/features/safari/">Safari</a>.</p>
<p>At this time Privoxy is ready to run and now all we need to do is to tell Squid to use Privoxy as a parent proxy:</p>
<pre class="code">cache_peer localhost parent 8118 7 no-digest no-query</pre>
<p>We built a chain of proxies: first our request goes to Squid which in turn hands it to Privoxy. You might ask why we bothered to setup Squid at all. Shouldn&#8217;t it be sufficient just to use Privoxy? This highly depends on the features you&#8217;d like to have: a sophisticated cache and the possibility of a <a title="Transparent proxy with Squid" href="http://www.christianschenk.org/blog/transparent-proxy-with-squid/">transparent proxy</a> are strong reasons for Squid. If you&#8217;re somewhere just with your notebook, e.g. in some office, you might want to opt for Privoxy without a Squid, because there may be already a proxy and you just want to obfuscate the requests you make to that proxy.</p>
<h3>Tuning Privoxy</h3>
<p>In the default installation of Privoxy on Debian systems there are a lot of other filters enabled, which remove ads and the like. All this content filtering can slow things down and use a good deal of processing time, i.e. massive CPU usage. I recommend turning off the filtering in Privoxy and suggest using a Firefox plugin like <a title="Adblock Plus Homepage" href="http://adblockplus.org/">Adblock Plus</a>.</p>
<p>If you&#8217;d like to disable the filtering done by Privoxy, change the following in the <em>config</em> file: comment out all lines starting with </p>
<ul>
<li><em>actionsfile</em> except:
<pre class="code">actionsfile default</pre>
</li>
<li><em>filterfile</em></li>
</ul>
<p>In the file <em>default.action</em>:</p>
<ul>
<li>There&#8217;s a block matching all URLs. Delete all <em>filter</em> lines.</li>
<li>Comment out everything below:
<pre class="code">+add-header{X-Actions-File-Version: 1.8}</pre>
</li>
</ul>
<p>That&#8217;s it. Now Privoxy will run a lot faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/enhancing-your-privacy-using-squid-and-privoxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>0</slash:comments>
		</item>
		<item>
		<title>Using a parent proxy with Squid</title>
		<link>http://www.christianschenk.org/blog/using-a-parent-proxy-with-squid/</link>
		<comments>http://www.christianschenk.org/blog/using-a-parent-proxy-with-squid/#comments</comments>
		<pubDate>Tue, 23 Jan 2007 15:50:45 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/using-a-parent-proxy-with-squid/</guid>
		<description><![CDATA[Shows how to use one or more parent proxies with Squid]]></description>
			<content:encoded><![CDATA[<p>If you want <a title="Squid Web Proxy Cache" href="http://www.squid-cache.org/">Squid</a> to be part of a hierarchy of proxies or you just want Squid to fetch content not directly from a web server but rather indirectly from another proxy then read on how to do that.</p>
<p><span id="more-8"></span></p>
<p>You can use the <em>cache_peer</em> directive to add parent proxies which Squid will ask for content. Furthermore you can control whether content will be fetched directly or indirectly with <em>always_direct</em> or <em>never_direct</em> respectively. For example</p>
<pre class="code">cache_peer proxy.some-isp.com parent 8080 0 no-query no-digest
never_direct allow all</pre>
<p>would tell Squid to always fetch content from the parent proxy, which is located at <em>proxy.some-isp.com:8080</em>. If we wouldn&#8217;t use the second directive there may be certain circumstances where Squid would ask directly for content and would ignore the parent proxy; this isn&#8217;t what we want.</p>
<p>There are a lot of <a title="Peer cache servers and Squid hierarchy" href="http://www.visolve.com/squid/squid24s1/neighbour.php#cache_peer">options</a> available which I don&#8217;t want to discuss here, because they are very well documented, but <em>no-query</em> and <em>no-digest</em> say that no ICP requests or cache digests should be send to the parent proxy (read: nagging should be turned off <img src='http://www.christianschenk.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ).</p>
<h2>Multiple parent proxies</h2>
<p>If you would like to have more than one parent proxy you can add more <em>cache_peer</em> directives; one for each parent. Now you can define either <em>weight</em> or <em>round-robin</em> to control the way Squid will communicate with the proxies: while <a title="Documentation for weight option" href="http://www.visolve.com/squid/squid24s1/glossary.php#weight">weight</a> tells Squid to prefer one cache over another, <a title="Documentation for round-robin option" href="http://www.visolve.com/squid/squid24s1/glossary.php#round-robin">round-robin</a> tries to spread connections evenly among the defined caches.</p>
<p>First of all a simple example for two parent proxies:</p>
<pre class="code">cache_peer proxy.isp1.com parent 8080 0 no-query no-digest default
cache_peer proxy.isp2.com parent 8080 0 no-query no-digest</pre>
<p>If you define more than one parent proxy you might want to set one as the <a title="Documentation for default option" href="http://www.visolve.com/squid/squid24s1/glossary.php#default">default</a> proxy, which is used as a last resort.</p>
<p>An example for weight:</p>
<pre class="code">cache_peer proxy.isp1.com parent 8080 0 no-query no-digest weight=1
cache_peer proxy.isp2.com parent 8080 0 no-query no-digest weight=2</pre>
<p>In this example it is likely that the proxy from the second ISP will be favored over the first one.</p>
<p>And here an example for round-robin:</p>
<pre class="code">cache_peer proxy.isp1.com parent 8080 round-robin no-query
cache_peer proxy.isp2.com parent 8080 round-robin no-query
cache_peer proxy.isp3.com parent 8080 round-robin no-query</pre>
<p>All connections to our proxy would be round-robined among these three caches. Because Squid treats all parents equally, it is currently not possible to define a weight here, e.g. to forward 50% of the requests to the first proxy and 25% to the second and third proxy respectively.</p>
<h2>Conclusion</h2>
<p>This post documents how to configure Squid to use a parent proxy or various parent proxies. Please have a look at the most recent documentation to learn more about the configuration details and features available in the latest version of Squid.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/using-a-parent-proxy-with-squid/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Transparent proxy with Squid</title>
		<link>http://www.christianschenk.org/blog/transparent-proxy-with-squid/</link>
		<comments>http://www.christianschenk.org/blog/transparent-proxy-with-squid/#comments</comments>
		<pubDate>Mon, 22 Jan 2007 09:05:08 +0000</pubDate>
		<dc:creator>Christian Schenk</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://www.christianschenk.org/blog/transparent-proxy-with-squid/</guid>
		<description><![CDATA[This post shows you how to setup a transparent proxy with Squid in some easy to follow steps]]></description>
			<content:encoded><![CDATA[<p>If you ever wanted to know how to setup a transparent proxy with <a title="Squid Web Proxy Cache" href="http://www.squid-cache.org/">Squid</a>, because either you are just curious or you have more than one computer from which you want to surf the internet, and you don&#8217;t want to set the proxy manually, then this might be something for you.</p>
<p>I will assume that we have two networks: 172.16.0.0/24 and 172.16.1.0/24. These networks are connected to our router via eth1 and eth2 respectively, while the router itself has the IPs 172.16.0.1 and 172.16.1.1.</p>
<p><span id="more-7"></span></p>
<h2>Setup</h2>
<p>If you&#8217;re running Debian you have a newer or older version of Squid installed, depending on the <a title="Debian-Releases" href="http://www.debian.org/releases/">release</a> you chose. At the time of this writing that might be 2.5.9 for Sarge aka stable or 2.6.5 for Etch aka testing. If you don&#8217;t already know the version, check your version with <em>dpkg -l squid.</em></p>
<p>For Squid 2.5.xx put the following into <em>/etc/squid/squid.conf</em>:</p>
<pre class="code">http_port 172.16.0.1:3128
http_port 172.16.1.1:3128
httpd_accel_host virtual
httpd_accel_port 80
httpd_accel_with_proxy on
httpd_accel_uses_host_header on</pre>
<p>and for Squid 2.6.xx:</p>
<pre class="code">http_port 172.16.0.1:3128 transparent
http_port 172.16.1.1:3128 transparent
always_direct allow all</pre>
<p>The last directive was a workaround for early 2.6 versions of Squid, because of this <a title="Unable to forward this request at this time" href="http://www.squid-cache.org/bugs/show_bug.cgi?id=1650">bug</a>. With the current version <a title="Debian Bug - Transparent proxying does not work with Squid 2.6" href="http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=380117">it seems</a> that this isn&#8217;t a problem anymore, so just leave it out.</p>
<h2>Firewall</h2>
<p>We have to tweak the firewall, so that everybody who wants to surf the internet will go through our transparent proxy.</p>
<pre class="code">iptables -t nat -A PREROUTING -i eth1 -p tcp ! -d 172.16.0.0/24
         --dport 80 -j REDIRECT --to-port 3128
iptables -t nat -A PREROUTING -i eth2 -p tcp ! -d 172.16.1.0/24
         --dport 80 -j REDIRECT --to-port 3128</pre>
<h2>Access Control</h2>
<p>At last we want to allow the users in our network to connect to our proxy. In the <em>squid.conf</em> there is a line saying:</p>
<pre class="code">http_access allow localhost</pre>
<p>below that line you should put the following:</p>
<pre class="code">acl LAN src 172.16.0.0/24 172.16.1.0/24
http_access allow LAN</pre>
<p>That&#8217;s it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christianschenk.org/blog/transparent-proxy-with-squid/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
