<?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>CrapFlingingMonkey.com &#187; squid</title>
	<atom:link href="http://crapflingingmonkey.com/wp/tag/squid/feed/" rel="self" type="application/rss+xml" />
	<link>http://crapflingingmonkey.com/wp</link>
	<description>Coding to the beat, yo</description>
	<lastBuildDate>Fri, 22 Jul 2011 00:39:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3-aortic-dissection</generator>
		<item>
		<title>April Fools Prank &#8212; Changing Images With Squid</title>
		<link>http://crapflingingmonkey.com/wp/2010/03/april-fools-prank/</link>
		<comments>http://crapflingingmonkey.com/wp/2010/03/april-fools-prank/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 21:07:10 +0000</pubDate>
		<dc:creator>josh</dc:creator>
				<category><![CDATA[fun]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[prank]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>

		<guid isPermaLink="false">http://crapflingingmonkey.com/wp/?p=90</guid>
		<description><![CDATA[Well, that time is upon us&#8230; time for April Fools.  I&#8217;m not very good at coming up with good pranks, but a friend of mine, Chris Alef, gave me a great idea: swap all the product images on Backcountry.com for pictures of our management, provided at http://www.backcountrycorp.com/corporate/section/0/aboutus_team.html. Pretty simple, and funny idea, but how do [...]]]></description>
			<content:encoded><![CDATA[<p>Well, that time is upon us&#8230; time for April Fools.  I&#8217;m not very good at coming up with good pranks, but a friend of mine, Chris Alef, gave me a great idea: swap all the product images on Backcountry.com for pictures of our management, provided at http://www.backcountrycorp.com/corporate/section/0/aboutus_team.html.</p>
<p>Pretty simple, and funny idea, but how do you make it work?  It was a lot easier than I thought.  The first idea was to use a proxy, and route all traffic from the office through the proxy.  That seemed less than ideal &#8212; if the proxy went down, so would everyones web access.  Orders would stop shipping, buyers would stop buying, and I would be in a lot of trouble.  There had to be a less risky way to do it.  Well, our images (all static content I guess) are hosted on content.backcountry.com.  Limited to a single domain, eh?  We have an internal DNS, so if we could get content.backcountry.com to just be a proxy, changing only a few images, we could just update the dns to use the proxy.  Brilliant!</p>
<p>I started up an EC2 instance of Ubuntu, installed squid, and started configuring it.  I followed relatively the same pattern as the <a href="http://www.ex-parrot.com/pete/upside-down-ternet.html">Upside-Down-Ternet</a>, using a redirector.  In all, these are the configs I changed/used in /etc/squid/squid.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="conf" style="font-family:monospace;">redirect_children 20
http_access2 allow all
http_port 80 accel defaultsite=content.backcountry.com vport=80
cache_peer content.backcountry.com parent 80 0 no-query originserver</pre></div></div>

<p>where <strong>content.backcountry.com </strong>is the origin server (what to proxy), and /tmp/test.pl is the redirector.  Without the redirector, this would be a completely transparent proxy to static content.  Now, the redirector code:</p>

<div class="wp_syntax"><div class="code"><pre class="perl perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #0000ff;">$|</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span>;
&nbsp;
<span style="color: #0000ff;">@images</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2131.jpg'</span><span style="color: #339933;">,</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2132.jpg'</span><span style="color: #339933;">,</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2133.jpg'</span><span style="color: #339933;">,</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2135.jpg'</span><span style="color: #339933;">,</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2129.jpg'</span><span style="color: #339933;">,</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2134.jpg'</span><span style="color: #339933;">,</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2130.jpg'</span><span style="color: #339933;">,</span>
  <span style="">'http://www.backcountrycorp.com/images/newsletter/2231.jpg'</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>lt;&amp;gt;<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">my</span> <span style="color: #0000ff;">$tmp</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">$_</span>;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$tmp</span> <span style="color: #339933;">=~</span> <span style="color: #009966; font-style: italic;">/images\/items\/medium/</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #0000ff;">$images</span><span style="color: #009900;">&#91;</span><span style="color: #000066;">int</span> <span style="color: #000066;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #000066;">scalar</span> <span style="color: #0000ff;">@images</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> . <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066;">print</span> <span style="color: #0000ff;">$tmp</span>;
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Restart squid, and done!  Now just test it by updating your /etc/hosts to add the ip of the proxy and content.backcountry.com.  Behold, the result:</p>
<div id="attachment_105" class="wp-caption alignleft" style="width: 310px"><a href="http://crapflingingmonkey.com/wp/wp-content/uploads/2010/03/00000019.png"><img class="size-medium wp-image-105" title="April Fools Prank" src="http://crapflingingmonkey.com/wp/wp-content/uploads/2010/03/00000019-300x197.png" alt="Jill looks good, doesn't she?" width="300" height="197" /></a><p class="wp-caption-text">Jill looks good, doesn&#39;t she?</p></div>
<p>I ended up not doing it.  I really didn&#8217;t feel it was worth losing my job by messing up.  If I could have found a better way to do it than updating the DNS, even the internal one, I would have done it.  But it was just too risky at my company.  Oh well, now you all know how to do it <img src='http://crapflingingmonkey.com/wp/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://crapflingingmonkey.com/wp/2010/03/april-fools-prank/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

