Installing Squid Proxy on Windows Home Server

UPDATE: I have another version of HOWTO that describes how Squid Proxy could be installed on Windows Home Server. It is much less technical and could be followed almost by everyone as it presents every step with screenshots. You are advised to first take a look at this post: Installing Squid on Windows Home Server (WHS) 2011.

Well I must admit that I have lately reopened Windows for myself… not all flavours of Windows of course but the one that most probably suits small home networks – namely Windows Home Server (WHS). It is such a nice collection of software that makes it easy for you to deploy something central in your homework and finally quit carring USBs around when your wife feels like watching that old romantic movie again or your kids scream loudly of the idea that they could see some photos from their baby time. You may be sure it all could be done easily with WHS.

But… as you have probably seen from my previous posts that I am a bit obsessed with content filtering… and having a central server for my sharing and backup needs means nothing to me when I can not install anything filtering on it. So to make it right one would need to install a proxy that could be used as cache and filtering for my family Internet access. And I do not know any kind of web proxying software more capable of doing it as Squid.

The main Squid web site contains a zip file with binaries built specifically for Windows (see http://wiki.squid-cache.org/SquidFaq/BinaryPackages). Being a technical person it is not a problem for me to follow the instructions in the README and set up the proxy on WHS but think of all those proud family fathers who are not that technical… they would need not a zip binary but nice looking simple and classical windows installation package (also known as MSI). So let us make us all a favor and create one!

Step 1. Download Windows binaries for Squid and Wix

Note: we will be using folder m:\squidwindowsmsi as working folder for our MSI project.

The Squid binaries for Windows can be downloaded from the Acme Consulting web site at address http://squid.acmeconsulting.it/. As of this writing the last stable version of Squid was 2.7. So go ahead and download the file squid-2.7.STABLE8-bin.zip. When download finishes unpack it into m:\squidwindowsmsi\2.7. You should get something like this:

The site of Acme Consulting contains detailed installation instructions on how to get Squid up and running and we will wrap these instructions into a nice small MSI installation package. And what real programmers use for creation of nice small MSI packages? Yes they use Wix of course!

For those who do not know (I also did not know it two years ago, so do not worry šŸ™‚ ) Wix is a free open source toolset aimed at easy creation of MSI installations for Windows (see more at http://wix.sourceforge.net) and was originally designed by guys from Microsoft so they must know exactly how this should be done :).

Go ahead and download the latest version of Wix toolset from SourceForge. As of this writing the latest stable version was 3.5. After download finishes unpack the downloaded file into m:\squidwindowsmsi\wix35. After unpacking you should get something like this:

Step 2. Create main.wix file

Wix toolset acts like a compiler – you create a source file (*.wix), describe what and where to install and then run candle.exe and light.exe command line utilities in order to get the MSI package. The internet is full of nice tutorials devoted to Wix so I am not going to repeat it all here. Though some points to take into account are:

  1. Squid wants to be installed onto disk C:, folder squid so it means we have to tweak the installer into thinking the TARGET directory for MSI is C:\squid. This can be done easily running the following custom actions:


    <!-- install on C: --->
    <CustomAction Id="AssignTargetDir" Property="TARGETDIR" Value="C:\" Execute="firstSequence" />
    <InstallUISequence>
    <Custom Action="AssignTargetDir" Before="CostInitialize">TARGETDIR=""</Custom>
    </InstallUISequence>
    <InstallExecuteSequence>
    <Custom Action="AssignTargetDir" Before="CostInitialize">TARGETDIR=""</Custom>
    </InstallExecuteSequence>

  2. When we install into location other than Program Files all components MUST have associated GUIDs. Sounds like quite easy to do but think of ALL those ~1000 files that are part of the squid installation… so in order to do that it would be nice to have some PowerShell brewed in:


    $refs = @()
    $path = "m:\squidwindowsmsi\2.7\squid\share\errors"
    $result = Dir($path)
    $result | foreach {

    $name = $_.Name
    write-host "<DirectoryRef Id='$name'>"

    $sub = Dir($path + "\" + $name)
    $sub | foreach {
    $line = $_
    $guid = "{"+[System.Guid]::NewGuid().toString().toUpper()+"}";
    write-host "<Component Id='$name`_$line' Guid='$guid'>"
    write-host " <File Id='$name`_$line' Name='$line' KeyPath='yes' DiskId='1' Vital='yes' Source='`$(var.OUTDIR)\squid\share\errors\$name\$line'/>"
    write-host "</Component>"

    $refs += "<ComponentRef Id='$name`_$line'/>"
    }
    write-host "</DirectoryRef>"
    }
    $refs | foreach {
    write-host $_
    }

  3. We would need several custom icons and bitmaps that could make our installer look better… the easiest and nicest ones are located on the squid web site in the section “Squid artwork
  4. Post installation steps (renaming configuration files, creating cache directories and installing Squid as a service) will be done from batch based custom action that would run the command file installed into c:\squid\bin\post_install.bat. Code to run the custom action is:


    <CustomAction Id="PostInstall" ExeCommand="[INSTALLDIR]bin\post_install.bat" Directory="INSTALLDIR" Execute="deferred" Return="check"/>
    <InstallExecuteSequence>
    <Custom Action="PostInstall" After="InstallFiles">NOT Installed</Custom>
    </InstallExecuteSequence>

Other parts of the WXS file are very common and simple. We will also create a batch file to ease the light and candle compilation and revision numbering. Contents of the batch file is pretty obvious and are out of the interest now šŸ™‚

Step 3. Build and share our work

Typing build_msi.bat in the m:\squidwindowsmsi is sufficient to product fully blown MSI installer for Squid. It can be installed, uninstalled on the Windows Home Server without problems. All your home network browsers are now capable of using open sourced, free and well known Squid proxy for efficient caching of web traffic.


Well (would you say) but where are the files themselves, we need files and not instructions to get going! If you really need them here they are http://squidwindowsmsi.sourceforge.net. We have created a SourceForge based project to share our findings with you. Feel free to comment and join development!

About sichent

sichent
This entry was posted in Network, proxy, squid, WHS. Bookmark the permalink.

4 Responses to Installing Squid Proxy on Windows Home Server

  1. Kevin says:

    Ummmm???? I think you skip like 10 steps cause this makes no sense at all (I’m one of the people you mention who probably won’t understand the README file..) Sorry, just need to let you know.

    • sichent says:

      Yes it is always hard to draw the line… i guess most of the text here could have been clearly written… but there from my point of view is another way – give a try to MSI installer of squid and if something NOT works – file a bug and we or some other guy who knows Wix will try to fix it šŸ™‚

    • sichent says:

      Kevin, I have written another post that tries to explicitly picture all the steps involved, but Squid is now installed on the WHS 2011.

  2. Pingback: Installing Squid on Windows Home Server (WHS) 2011 | sichent

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s