<?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; Splunk</title>
	<atom:link href="http://www.laneolson.ca/tag/splunk/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>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>
	</channel>
</rss>

