<?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>laneolson.ca &#187; apache</title>
	<atom:link href="http://www.laneolson.ca/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.laneolson.ca</link>
	<description></description>
	<lastBuildDate>Fri, 07 Jan 2011 23:06:53 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Installing and Configuring Apache for Multiple Sites on Ubuntu</title>
		<link>http://www.laneolson.ca/2010/02/11/installing-and-configuring-apache-for-multiple-sites-on-ubuntu/</link>
		<comments>http://www.laneolson.ca/2010/02/11/installing-and-configuring-apache-for-multiple-sites-on-ubuntu/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 21:21:27 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.laneolson.ca/?p=162</guid>
		<description><![CDATA[<p>I like to run a local version of <a href="http://apache.org/">Apache</a> on my laptop for various projects so I can bring them wherever I go and not have to worry about them being live or screwing anything up.  Ubuntu makes it extremely easy to setup a LAMP server.  All you have to do is run:</p>

<div class="wp_syntax"><div class="code"><pre style="font-family: monospace;" class="bash"><span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> tasksel</pre></div></div>

<p>Then follow the onscreen instructions and choose “LAMP Server” when prompted to be up and running with Apache, MySQL, and PHP in mere minutes.</p><p>This is great for a user that just wants the standard versions of PHP or MySQL.  However, I’m working on a project that requires PHP 5.3, and installing a LAMP server using tasksel installs PHP 5.2.  I decided that I would just install Apache and PHP manually so that I could use PHP 5.3.  This guide starts with my ideal Apache setup.  This is kind of a personal preference of how I like Apache setup, others may prefer a different method.  If you follow this guide directly you will end up with your web directory in your home folder, with two sites (http://sandbox.local/ and http://production.local/).  Lets get started.</p>
<h3>Installing Apache</h3>
<p>Installing Apache is the easy part, simply use apt:</p>

<div class="wp_syntax"><div class="code"><pre style="font-family: monospace;" class="bash"><span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">install</span> apache2 apache2-prefork-dev apache2-mpm-prefork</pre></div></div>

<p>Let it do its thing and in a few minutes you should have Apache up and running.  Once it is done you can test if it is working by opening a web browser and entering http://localhost/ in the address bar.  You should get Apache’s default message that says “It works!”.  Now that Apache is installed we can configure it to fit our needs...</p>]]></description>
			<content:encoded><![CDATA[<p>I like to run a local version of <a href="http://apache.org/">Apache</a> on my laptop for various projects so I can bring them wherever I go and not have to worry about them being live or screwing anything up.  Ubuntu makes it extremely easy to setup a LAMP server.  All you have to do is run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> tasksel</pre></div></div>

<p>Then follow the onscreen instructions and choose &#8220;LAMP Server&#8221; when prompted to be up and running with Apache, MySQL, and PHP in mere minutes.  This is great for a user that just wants the standard versions of PHP or MySQL.  However, I&#8217;m working on a project that requires PHP 5.3, and installing a LAMP server using tasksel installs PHP 5.2.  I decided that I would just install Apache and PHP manually so that I could use PHP 5.3.  This guide starts with my ideal Apache setup.  This is kind of a personal preference of how I like Apache setup, others may prefer a different method.  If you follow this guide directly you will end up with your web directory in your home folder, with two sites (http://sandbox.local/ and http://production.local/).  Lets get started.</p>
<h3>Installing Apache</h3>
<p>Installing Apache is the easy part, simply use apt:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 apache2-prefork-dev apache2-mpm-prefork</pre></div></div>

<p>Let it do its thing and in a few minutes you should have Apache up and running.  Once it is done you can test if it is working by opening a web browser and entering http://localhost/ in the address bar.  You should get Apache&#8217;s default message that says &#8220;It works!&#8221;.  Now that Apache is installed we can configure it to fit our needs.</p>
<h3>Configuring Apache</h3>
<p>The first thing we are going to do is edit our hosts file to include our two &#8220;domain names&#8221; we&#8217;ll be using for the site, sandbox.local and production.local.  Open up the /etc/hosts file with nano (or your editor of choice):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>hosts</pre></div></div>

<p>And add the following lines below the line that begins with 127.0.1.1:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">127.0.1.2 sandbox.local www.sandbox.local
127.0.1.3 production.local www.production.local</pre></div></div>

<p>For those not familiar with the hosts file, what this is doing is assigning an IP Address to the host names.  127.0.1.2 and 127.0.1.3 are IP addresses that point to the local machine.  The values following the IP Address are the host name, and host alias respectively.  If you want to additional host names that point to the local machine then add them here.  You can call your host names whatever you like instead of sandbox.local and production.local, just be sure to substitute your own names in place of these for the rest of the tutorial.</p>
<p>Now that we have our host names pointing to our local machine we can create directories to hold the content for our two websites.  I created my base web directory inside of my home directory:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>www</pre></div></div>

</pre>
<p>Now I want a directory for each site inside of the www directory.  The following will make a directory for each site with sub directories for the type of content (httpdocs for the web files, logs for the logs).  The last line just creates an index.html file in the httpdocs directory so we can test that our websites are working later.</p>
<p>For the sandbox.local website:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local<span style="color: #000000; font-weight: bold;">/</span>logs
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;h1&gt;sandbox.local&lt;/h1&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs<span style="color: #000000; font-weight: bold;">/</span>index.html</pre></div></div>

<p>For the production.local website:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local<span style="color: #000000; font-weight: bold;">/</span>logs
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;&lt;h1&gt;production.local&lt;/h1&gt;&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> ~<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs<span style="color: #000000; font-weight: bold;">/</span>index.html</pre></div></div>

<p>Now we have our host names setup, and directories setup that contain our website.  The next step is to create configuration files to tell Apache what our host name (domain name) is and where on the computer it is located.  The configuration files for each site should be created in "/etc/apache2/sites-available".</p>
<p>First lets create the configuration file for sandbox.local</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> sandbox.local</pre></div></div>

<p>The file sandbox.local should contain the following.  You will have to change the "ServerAdmin" value and all the instances of "/home/lane" to your home directory depending on your username.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	ServerAdmin username<span style="color: #000000; font-weight: bold;">@</span>sandbox.local
	ServerName sandbox.local
	ServerAlias www.sandbox.local
&nbsp;
	DocumentRoot <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs<span style="color: #000000; font-weight: bold;">/</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs<span style="color: #000000; font-weight: bold;">/&gt;</span>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	ErrorLog <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>error.log
	LogLevel warn
	CustomLog <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>sandbox.local<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>access.log combined
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Now do the same for production.local.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">nano</span> production.local</pre></div></div>

<p>With contents:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>VirtualHost <span style="color: #000000; font-weight: bold;">*</span>:<span style="color: #000000;">80</span><span style="color: #000000; font-weight: bold;">&gt;</span>
	ServerAdmin username<span style="color: #000000; font-weight: bold;">@</span>production.local
	ServerName production.local
	ServerAlias www.production.local
&nbsp;
	DocumentRoot <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs<span style="color: #000000; font-weight: bold;">/</span>
	<span style="color: #000000; font-weight: bold;">&lt;</span>Directory <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local<span style="color: #000000; font-weight: bold;">/</span>httpdocs<span style="color: #000000; font-weight: bold;">/&gt;</span>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	<span style="color: #000000; font-weight: bold;">&lt;/</span>Directory<span style="color: #000000; font-weight: bold;">&gt;</span>
&nbsp;
	ErrorLog <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>error.log
	LogLevel warn
	CustomLog <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>lane<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>production.local<span style="color: #000000; font-weight: bold;">/</span>logs<span style="color: #000000; font-weight: bold;">/</span>access.log combined
<span style="color: #000000; font-weight: bold;">&lt;/</span>VirtualHost<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>As you can see the two configuration files are pretty straight forward XML files.  The <a href="http://httpd.apache.org/docs/1.3/mod/core.html#servername">ServerName</a> and <a href="http://httpd.apache.org/docs/1.3/mod/core.html#serveralias">ServerAlias</a> values tell Apache what host name the following configuration is meant for.  The <a href="http://httpd.apache.org/docs/1.3/mod/core.html#documentroot">DocumentRoot</a> value tells Apache where to find the files for this website.  The <a href="http://httpd.apache.org/docs/1.3/mod/core.html#directory">Directory directive</a> allows you to specify specific options for the given directory.  Lastly the <a href="http://httpd.apache.org/docs/1.3/mod/core.html#errorlog">ErrorLog</a> and <a href="http://httpd.apache.org/docs/1.3/mod/mod_log_config.html#customlog">CustomLog</a> tells Apache where to store the log files for this domain.</p>
<p>Once the configuration files have been created we want to enable them so that Apache knows they are there.  I also chose to disable the default config, this is up to you.  The default config will load whatever is in "/var/www" when you point your browser to "localhost" (which is why we recieved the "It works!" message earlier.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2ensite sandbox.local
<span style="color: #c20cb9; font-weight: bold;">sudo</span> a2ensite production.local
<span style="color: #c20cb9; font-weight: bold;">sudo</span> a2dissite default</pre></div></div>

<p>Finally the last step is to restart Apache.  This can be done with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

<p>If all went well we should be able to bring up our two new local websites.  Here is where everything we've done comes together.  Open up your web browser and type in "http://sandbox.local/".  When you type in sandbox.local in your web browser, the host name is looked up (and found in /etc/hosts) which points to the localhost (127.0.1.2).  Apache is listening on port 80 (the default http port) and picks up the request for "sandbox.local".  It looks in the enabled sites for one with a ServerName of "sandbox.local" then points to the requested file (index.html by default) in "DocumentRoot".  The web browser then displays this page and should say "sandbox.local" in big letters.</p>
<p>Now point your web browser to http://production.local/ and you should receive a similar page that says "production.local" in big letters.</p>
<p>You can now put whatever web content you want in ~/www/sandbox.local/httpdocs/ or ~/www/production.local/httpdocs/ and they will load up when you type their host name into your web browser.</p>
<p>This isn't really all that useful yet because all you can load up are html pages, which you could do anyways just by double clicking on an html file.  In my next blog post I will show you how to install PHP for use with your Apache web server so you can use it as a testing ground for various projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.laneolson.ca/2010/02/11/installing-and-configuring-apache-for-multiple-sites-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Splunk with SSL and Password Protection Using Apache</title>
		<link>http://www.laneolson.ca/2009/07/08/splunk-with-ssl-and-password-protection-using-apache/</link>
		<comments>http://www.laneolson.ca/2009/07/08/splunk-with-ssl-and-password-protection-using-apache/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 19:31:39 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[Security]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Splunk]]></category>

		<guid isPermaLink="false">http://www.laneolson.ca/?p=90</guid>
		<description><![CDATA[<p>Splunk is probably the greatest tool that I've found for managing pretty much any kind of data.  Firewalls, switches, windows servers, software logs... the list goes on!  The creators of Splunk generously offer a free version with a few limitations which is perfect for those of us who aren't huge enterprises.  Unfortunately, one of the limitations is the lack of some type of authentication which is pretty crucial if your logs contain sensitive data.  I've configured my Splunk installation so that it requires authetication through an Apache proxy.  I've also enabled SSL to allow for encryption of web traffic.  The following guide outlines the steps I followed in order to do so on Ubuntu 9.04.  This is mostly just a combination of the following guides into one:</p>
<ul>
<li><a href="http://www.deckerd.com/core/splunk-free-htaccess-protection-using-apache/">Splunk htaccess Authentication</a></li>
<li>
<a href="http://www.tc.umn.edu/~brams006/selfsign_ubuntu.html">SSL Setup</a>
</li>
<li>
<a href="http://ubuntuforums.org/showthread.php?t=159661">IPtables setup</a>
</li>
</ul>
<p>I recommend viewing them for a more detailed explanation.</p>
<p>This guide assumes you have a fresh installation of Splunk but should work fine with an existing one.  If you don't have a Splunk installation yet, you can install it quite easily:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">'http://www.splunk.com/index.php/download_track?file=3.4.10/linux/splunk-3.4.10-60883-Linux-i686.tgz&#38;ac=&#38;wget=true&#38;name=wget&#38;typed=releases'</span> 
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xvfz splunk-3.4.10-<span style="color: #000000;">60883</span>-Linux-i686.tgz
<span style="color: #c20cb9; font-weight: bold;">sudo</span> splunk<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>splunk start
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>splunk<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>splunk <span style="color: #7a0874; font-weight: bold;">enable</span> boot-start</pre></div></div> 
<p><em><strong>Note:</strong> Make sure you obtain the latest release.  The address in the above wget is probably not the most recent version.</em></p>
<p>
You will also want to enable https on the Splunk installation.  You can do this bygoing to http://127.0.0.1:8000/ and clicking the Admin link on the top right part of Splunk Web. </p>]]></description>
			<content:encoded><![CDATA[<p>Splunk is probably the greatest tool that I&#8217;ve found for managing pretty much any kind of data.  Firewalls, switches, windows servers, software logs&#8230; the list goes on!  The creators of Splunk generously offer a free version with a few limitations which is perfect for those of us who aren&#8217;t huge enterprises.  Unfortunately, one of the limitations is the lack of some type of authentication which is pretty crucial if your logs contain sensitive data.  I&#8217;ve configured my Splunk installation so that it requires authetication through an Apache proxy.  I&#8217;ve also enabled SSL to allow for encryption of web traffic.  The following guide outlines the steps I followed in order to do so on Ubuntu 9.04.  This is mostly just a combination of the following guides into one:</p>
<ul>
<li><a href="http://www.deckerd.com/core/splunk-free-htaccess-protection-using-apache/">Splunk htaccess Authentication</a></li>
<li>
<a href="http://www.tc.umn.edu/~brams006/selfsign_ubuntu.html">SSL Setup</a>
</li>
<li>
<a href="http://ubuntuforums.org/showthread.php?t=159661">IPtables setup</a>
</li>
</ul>
<p>I recommend viewing them for a more detailed explanation.</p>
<p>This guide assumes you have a fresh installation of Splunk but should work fine with an existing one.  If you don&#8217;t have a Splunk installation yet, you can install it quite easily:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>opt
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">wget</span> <span style="color: #ff0000;">'http://www.splunk.com/index.php/download_track?file=3.4.10/linux/splunk-3.4.10-60883-Linux-i686.tgz&amp;ac=&amp;wget=true&amp;name=wget&amp;typed=releases'</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xvfz splunk-3.4.10-<span style="color: #000000;">60883</span>-Linux-i686.tgz
<span style="color: #c20cb9; font-weight: bold;">sudo</span> splunk<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>splunk start
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>splunk<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>splunk <span style="color: #7a0874; font-weight: bold;">enable</span> boot-start</pre></div></div>

<p><em><strong>Note:</strong> Make sure you obtain the latest release.  The address in the above wget is probably not the most recent version.</em></p>
<p>You will also want to enable https on the Splunk installation.  You can do this bygoing to http://127.0.0.1:8000/ and clicking the Admin link on the top right part of Splunk Web.  Then in the <b>Server: View Settings</b> page under <b>Splunk Web</b> set <em>Enable SSL (HTTPS) in Splunk Web?</em> to <b>Yes</b>.  Restart Splunk and you should now be able to access it with an https prefix.</p>
<p>For this guide you are also going to need apache2, openssl.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> apache2 openssl</pre></div></div>

<p>Once apache has installed you have to enable the required modules:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod proxy
<span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod proxy_http
<span style="color: #c20cb9; font-weight: bold;">sudo</span> a2enmod ssl</pre></div></div>

<p>The proxy modules are required because we are going to be taking requests on port 80 and those requests will be forwarded to the Splunk web interface on port 8000.</p>
<p>Now I am not going to go into extreme detail about generating certificates as this could be a whole topic in itself.  Check out Paul Bramscher&#8217;s page on <a href="http://www.tc.umn.edu/~brams006/selfsign.html">generating self signed certificates</a> if you want more details.</p>
<p>The first step is to go to your home directory and generate a server key:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> ~
<span style="color: #c20cb9; font-weight: bold;">sudo</span> openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> server.key <span style="color: #000000;">4096</span></pre></div></div>

<p>Next create a certificate signing request with the server key.  You will be asked a series of questions, answer them as you see fit:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> server.key <span style="color: #660033;">-out</span> server.csr</pre></div></div>

<p>Now sign the certificate signing request.  This one is valid for 1000 days, you may use whatever you like:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> openssl x509 <span style="color: #660033;">-req</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">1000</span> <span style="color: #660033;">-in</span> server.csr <span style="color: #660033;">-signkey</span> server.key <span style="color: #660033;">-out</span> server.crt</pre></div></div>

<p>Now make a version that does not require a password:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> openssl rsa <span style="color: #660033;">-in</span> server.key <span style="color: #660033;">-out</span> server.key.insecure
<span style="color: #c20cb9; font-weight: bold;">mv</span> server.key server.key.secure
<span style="color: #c20cb9; font-weight: bold;">mv</span> server.key.insecure server.key</pre></div></div>

<p>Lastly copy the key and certificate that do not require a password to the designated apache folder:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>ssl
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> server.key <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>ssl
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> server.crt <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>ssl</pre></div></div>

<p>That&#8217;s it for the certificates!  Now we can start configuring apache.  Create a configuration file for the ssl setup:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>sites-available<span style="color: #000000; font-weight: bold;">/</span>ssl</pre></div></div>

<p>You will want to enter something similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">443</span>&gt;
        <span style="color: #00007f;">ServerAdmin</span> webmaster@domain.com
        <span style="color: #00007f;">ServerAlias</span> machine.domain.com
        <span style="color: #00007f;">ProxyPass</span> / https://127.0.0.1:<span style="color: #ff0000;">8000</span>/
        <span style="color: #00007f;">ProxyPassReverse</span> / https://127.0.0.1:<span style="color: #ff0000;">8000</span>/
        <span style="color: #00007f;">ErrorLog</span> /var/log/apache2/error.log
        <span style="color: #00007f;">CustomLog</span> /var/log/apache2/access.log combined
        SSLEngine <span style="color: #0000ff;">On</span>
        SSLCertificateFile /etc/apache2/ssl/server.crt
        SSLCertificateKeyFile /etc/apache2/ssl/server.key
        SSLProxyEngine <span style="color: #0000ff;">on</span>
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;
&lt;<span style="color: #000000; font-weight:bold;">Proxy</span> https://127.0.0.1:<span style="color: #ff0000;">8000</span>/*&gt;
        <span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>
        <span style="color: #00007f;">Deny</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>
        <span style="color: #00007f;">Allow</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>
        <span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;machine.domain.com&quot;</span>
        <span style="color: #00007f;">AuthType</span> Basic
        <span style="color: #00007f;">AuthUserFile</span> /var/www/.htpasswd
        <span style="color: #00007f;">Require</span> valid-<span style="color: #00007f;">user</span>
&lt;/<span style="color: #000000; font-weight:bold;">Proxy</span>&gt;</pre></div></div>

<p>The ServerAlias will be whatever your DNS name for your Splunk server is.</p>
<p>Now enable the site we just set up:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> a2ensite ssl</pre></div></div>

<p>You should also make sure that Apache is listening on port 443.  Do this:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>ports.conf</pre></div></div>

<p>Add this (if it does not already exist):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;</span>IfModule mod_ssl.c<span style="color: #000000; font-weight: bold;">&gt;</span>
    Listen <span style="color: #000000;">443</span>
<span style="color: #000000; font-weight: bold;">&lt;/</span>IfModule<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>Now the last step is setting up your user account in the .htpasswd file.  This can be done with the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> htpasswd <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>.htpasswd username</pre></div></div>

<p>Where username is replaced with the username you wish to use.  The -c flag creates the file, if you need to add multiple users do not use the -c flag after the first command or it will overwrite the file.</p>
<p>Now restart Apache:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 restart</pre></div></div>

<p>If all goes well you should be able to type in the https://machine.domain.com/ and you will receive a password prompt.  Enter the username/password you just created and you will be at Splunk Web!</p>
<p>Now, try typing in https://machine.domain.com:8000/ and see what happens.  You will probably be directed to Splunk web without being prompted for a password.  Uh oh&#8230; did you just do all this for nothing?!  Nope!  We can set up some ip table rules to prevent access to port 8000 to force users to use the proxy.  I won&#8217;t go into depth on this but we first allow access to port 8000 from localhost with the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-s</span> 127.0.0.1 <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">8000</span> <span style="color: #660033;">-j</span> ACCEPT</pre></div></div>

<p>Now we want to drop all other hosts from accessing port 8000:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> iptables <span style="color: #660033;">-A</span> INPUT <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">8000</span> <span style="color: #660033;">-j</span> DROP</pre></div></div>

<p>Now any attempts to access https://machine.domain.com:8000/ will be blocked, but access attempts to the password protected interface on port 443 will still be allowed.</p>
<p>You can also modify the above rules to limit access to the interface by IP address.  Just replace 127.0.0.1 with the IP address you wish to allow acces and change the dport to 443.  Enter one of these commands for each IP address to allow.  Then enter the second rule (with dport 443) once all the allowed hosts have been added.</p>
<p><em><strong>Note:</strong>  The iptables will not be reloaded when you reboot the Splunk machine.  I recommend following this <a href="http://ubuntuforums.org/showthread.php?t=159661" target="_blank">firewall guide</a> in order to have a configurable iptables script that loads on startup</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.laneolson.ca/2009/07/08/splunk-with-ssl-and-password-protection-using-apache/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Page Not Found When Posting or Editing WordPress Posts</title>
		<link>http://www.laneolson.ca/2009/05/22/page-not-found-when-posting-or-editing-wordpress-posts/</link>
		<comments>http://www.laneolson.ca/2009/05/22/page-not-found-when-posting-or-editing-wordpress-posts/#comments</comments>
		<pubDate>Fri, 22 May 2009 19:15:10 +0000</pubDate>
		<dc:creator>Lane</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://laneolson.ca/?p=47</guid>
		<description><![CDATA[Today I was copying over some old posts I had on another WordPress install and for some reason when I went to edit one of the posts I was redirected to a 404 error.  I thought this was odd, so I tried to repost the item as a new post.  I still received the 404 error!  After some Googling I found this blog post which outlined some solutions to this problem.  It appears that some people have had some luck using those solutions.  However, none of them worked for me&#8230; even encoding the whole post into HTML entities!  
It is indeed a problem with a security module in Apache.  If you are as unlucky as I was to still have the problem after trying out the solutions in the blog post above, then you have the joy of tracking down the specific word that appears to be the problem.  In my case, I was posting a code snippet from my post on Caching Data with CakePHP.  For some reason mod_security was flagging my use of the word &#8220;settings&#8221;.  Once I changed the variable names in the post it worked flawlessly.
]]></description>
			<content:encoded><![CDATA[<p>Today I was copying over some old posts I had on another WordPress install and for some reason when I went to edit one of the posts I was redirected to a 404 error.  I thought this was odd, so I tried to repost the item as a new post.  I still received the 404 error!  After some Googling I found <a href="http://abing.gotdns.com/posts/2006/wordpress-error-404-when-publishing-or-saving-post/" target="blank">this blog post</a> which outlined some solutions to this problem.  It appears that some people have had some luck using those solutions.  However, none of them worked for me&#8230; even encoding the whole post into HTML entities!  </p>
<p>It is indeed a problem with a security module in Apache.  If you are as unlucky as I was to still have the problem after trying out the solutions in the blog post above, then you have the joy of tracking down the specific word that appears to be the problem.  In my case, I was posting a code snippet from my post on Caching Data with CakePHP.  For some reason mod_security was flagging my use of the word &#8220;settings&#8221;.  Once I changed the variable names in the post it worked flawlessly.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.laneolson.ca/2009/05/22/page-not-found-when-posting-or-editing-wordpress-posts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

