<?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>Erics Tech Blog &#187; apache</title>
	<atom:link href="http://eric.lubow.org/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://eric.lubow.org</link>
	<description>Thoughts, musings, and other idealistic (sometimes useful) systems and development hoopla.</description>
	<lastBuildDate>Fri, 18 Nov 2011 14:56:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Mod-Security 2.5 by Magnus Mischel</title>
		<link>http://eric.lubow.org/2010/book-reviews/mod-security-2-5-by-magnus-mischel/</link>
		<comments>http://eric.lubow.org/2010/book-reviews/mod-security-2-5-by-magnus-mischel/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 10:30:05 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[mod_security]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/?p=509</guid>
		<description><![CDATA[Being a SysAdmin (as most of you who read this blog regularly know), I love to look at logs to solve problems. If there is an issue, the first thing I always do is look at the logs to see what went wrong. Even when I am writing programs, I build debugging in from the [...]]]></description>
			<content:encoded><![CDATA[<p>Being a SysAdmin (as most of you who read this blog regularly know), I love to look at logs to solve problems.  If there is an issue, the first thing I always do is look at the logs to see what went wrong.  Even when I am writing programs, I build debugging in from the beginning to make sure I know what&#8217;s going on at all times (especially when something goes wrong). <span id="more-509"></span> <div id="attachment_510" class="wp-caption alignright" style="width: 160px"><a href="http://eric.lubow.org/wp-content/uploads/2010/01/mod_security_cover.jpg"><img src="http://eric.lubow.org/wp-content/uploads/2010/01/mod_security_cover-150x150.jpg" alt="Mod Security 2.5 Cover" title="Mod Security 2.5" width="150" height="150" class="size-thumbnail wp-image-510" /></a><p class="wp-caption-text">Mod Security 2.5</p></div></p>
<p>One of my favorite things about mod_security is that (amongst other things), it provides logging where none was provided.  In fact, there is a whole chapter dedicated to it (chapter 4 on audit logging).  And thus the first chapter I went to (just for fun).  So I started flipping back and forth between chapters 2 (writing rules) and 4 (audit logging) to create my ruleset.  I quickly realized that it was going to be a pain to do it that way.  So I sucked it up and started reading the book.  I normally hate doing that because typically technical books read like watching paint dry, but this one read fairly easily.  I also happen to really like the type face conventions used by Packt Publishing to make examples separate from text separate from whatever else needs to stand out.</p>
<p>I skimmed chapter 1 because I not only have built programs including Apache modules in my time, but I have also setup mod_security 1 before.  This is why I was so excited to dive into this book since it has been a while and I wanted to see what has changed in mod_security over the years.</p>
<p>Right into chapter 2, I wrote a few logging rules and some protection from SQL injection.  And then I tried out the recipe to stop all visitors from the US from accessing the web site.  Needless to say that worked, so I apologize for the few min of downtime you all may have experienced.</p>
<p>Chapter 3 was inevitably about performance.  This is always a concern amongst admins.  Most of your fears are assuaged by chart after comparison chart of how Apache works under the load of <em>httperf</em> along with a few experience based suggestions on how to reduce Apache&#8217;s memory footprint and other helpful items.  It even tails off with optimizing how you employ regular expressions.</p>
<p>Now chapter 4 again, audit logging.  The logs themselves have quite a bit of information in them.  Although they can be read, it can be pretty tedious.  The mod_security console discussed in the book makes this a lot easier.</p>
<p>Virtual patching is an interesting concept that allows for the ability to apply a patch for a vulnerability without one being supplied by the vendor.  There are a few examples, including the Twitter worm of 2009 of where it can be practically applicable.  It is covered pretty extensively in chapter 5.</p>
<p>Chapter 6 is actually the meat of the book.  It is where the commonly used recipes are.  In fact, I have added more than a few of these recipe to some of the various web servers I run.</p>
<p>As a admin, one is usually concerned with security.  Let&#8217;s face it, why else would you be looking into mod_security?  If you are into host security, then have a look at chapter 7 about using chroot jails.  There is a section discussing where this is appropriate and if it is, how to implement it without having to put Apache fully in a chroot jail.</p>
<p>Just like any tool with an archaic interface for rules (like the original days of SELinux or configuring Nagios), there inevitably comes GUI tools. Remo is one of those tools.  One of the coolest things about Remo (in my opinion) is that its written in Rails and can therefore be run using either Webrick or another Rails engine (like Phusion Passenger in Apache or Mongrel).  If you don&#8217;t want to dive too heavily into the Apache config files, then give Remo a shot.</p>
<p>The book finishes up by showing an fairly detailed example ruleset for a live web application.  And really, who doesn&#8217;t have one of those (live web application).</p>
<p>Other than the one major editing flaw of labeling chapter 5 as chapter 9, the book was excellent.  Not only would I recommend this book to other SAs, I already have.  Besides being very readable, there are many recipes in this book that are immediately applicable and easily implemented.  Mod_security has a fairly low barrier to entry and the simplicity in this book proves it.  With the type of data and the amount of data being stored in web applications these days, extra security is a must.  </p>
<p>You can purchase the book from <a href="http://www.amazon.com/exec/obidos/tg/detail/-/1847194745">Amazon</a> or find other locations through <a href="http://www.packtpub.com/modsecurity-2-5/book">Packt Publishing</a>.</p>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2009/book-reviews/modsecurity-2-5-review-coming/' rel='bookmark' title='Modsecurity 2.5 Review Coming'>Modsecurity 2.5 Review Coming</a></li>
<li><a href='http://eric.lubow.org/2010/book-reviews/mysql-for-python/' rel='bookmark' title='MySQL for Python'>MySQL for Python</a></li>
<li><a href='http://eric.lubow.org/2007/book-reviews/building-telephony-systems-with-asterisk/' rel='bookmark' title='Building Telephony Systems With Asterisk'>Building Telephony Systems With Asterisk</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2010/book-reviews/mod-security-2-5-by-magnus-mischel/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Modsecurity 2.5 Review Coming</title>
		<link>http://eric.lubow.org/2009/book-reviews/modsecurity-2-5-review-coming/</link>
		<comments>http://eric.lubow.org/2009/book-reviews/modsecurity-2-5-review-coming/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 11:00:12 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Book Reviews]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/?p=420</guid>
		<description><![CDATA[The folks over at Packt Publishing are kind enough to send me out an advance copy of the upcoming Modsecurity book by Magnus Mischel. I have written about mod security before, but really haven&#8217;t had a chance to look into it recently. I am anxious to see where its advanced to in version 2.5. If [...]]]></description>
			<content:encoded><![CDATA[<p>The folks over at <a href="http://www.packtpub.com/">Packt Publishing</a> are kind enough to send me out an advance copy of the upcoming <a href="http://www.packtpub.com/modsecurity-2-5/book">Modsecurity book</a> by <a href="http://www.packtpub.com/author_view_profile/id/373">Magnus Mischel</a>.  I have written about mod security <a href="http://eric.lubow.org/2007/engarde/configuring-mod_security-for-engarde-secure-linux/">before</a>, but really haven&#8217;t had a chance to look into it recently.  I am anxious to see where its advanced to in version 2.5.</p>
<p>If you don&#8217;t know anything about <a href="http://www.modsecurity.org/">mod_security</a>, I encourage you to read up on it in the interim.</p>
<p>Stay tuned for the review.</p>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2010/book-reviews/mod-security-2-5-by-magnus-mischel/' rel='bookmark' title='Mod-Security 2.5 by Magnus Mischel'>Mod-Security 2.5 by Magnus Mischel</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2009/book-reviews/modsecurity-2-5-review-coming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Checking For A DoS</title>
		<link>http://eric.lubow.org/2008/linux-security/checking-for-a-dos/</link>
		<comments>http://eric.lubow.org/2008/linux-security/checking-for-a-dos/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 14:00:58 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Linux Security]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[ddos]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/blog/?p=50</guid>
		<description><![CDATA[Working on groups of web servers, especially ones that are highly susceptible to attack, it is a good idea to have a string of commands that will allow you to check what is going on. Check for DDos: netstat -n &#124; grep EST &#124; awk '{ print $5 }' &#124; cut -d: -f1 &#124; sort [...]]]></description>
			<content:encoded><![CDATA[<p>Working on groups of web servers, especially ones that are highly susceptible to attack, it is a good idea to have a string of commands that will allow you to check what is going on.</p>
<p>Check for DDos:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">netstat -n | grep EST | awk '{ print $5 }' | cut -d: -f1 | sort | uniq -c | sort -nr | perl -an -e 'use Socket; ($hostname, @trash) = gethostbyaddr(inet_aton($F[1]), AF_INET); print &quot;$F[0]\t$F[1]\t$hostname\n&quot;;'</div></div>
<p>Using this command will produce a list of hostnames that have a connect to the machine in an ESTABLISHED state.  This is handy for creating a firewall rule either on the host (iptables, ipfw) or a little further away from the machine (at the edge router).</p>
<p>Check for web attacks:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cat eric.lubow.org-access_log.20081015 | awk '{print $1 }' | sort | uniq -c | sort -nr | head | perl -an -e 'use Socket; ($hostname, @trash) = gethostbyaddr(inet_aton($F[1]), AF_INET); print &quot;$F[0]\t$F[1]\t$hostname\n&quot;;'</div></div>
<p>By using this command, you will get a hostname lookup on the IP sorted by total hit count descending.  As when checking for DDos attacks, you can use this information to write firewall rules.</p>
<p>More web attack checks:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">for i in `ls *.20081015 | grep -v error`; do echo &quot;##### $i ######&quot;; tail -n 10000 $i| awk '{print $1};' | sort -n | uniq -c | sort -nr | head -2; done</div></div>
<p>The difference between this check and the previous check is that this time, you may have a lot more logfiles to go through.  I am also assuming that they are stored by <sitename>.<date>.  They will print out which file its scanning and the top 2 issues from that file.</p>
<p>Referrer Check:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">for file in `ls -lrS *access*20080525* | tail -n20`; do echo &quot;==========&quot; $file; gawk --re-interval -F'&quot;' '{ split($4, myrt, &quot;/&quot;); &nbsp;split($0, myct); split(myct[3], myc, &quot; &quot;); if (length(myrt[3])==0) { myrt[3]=&quot;none&quot;}; if (myrt[3] ~ /([[:digit:]]{1,3}\.){3}[[:digit:]]{1,3}/) { referrers[myrt[3]&quot;/&quot;myc[1]]++; } else { t=split(myrt[3], myrt2, &quot;.&quot;); myref=&quot;*.&quot;myrt2[t-1]&quot;.&quot;myrt2[t]; referrers[myref&quot;/&quot;myc[1]]++; } } END { for (referrer in referrers) { print referrers[referrer], referrer } }' $file | grep -v none | sort -n; done</div></div>
<p>This last check will get the referrer for a page from the logs and count up the number of times that exact referrer drives traffic to your page.  Although this may initially appear to be only tangentially useful, if you are getting DDos, it may be hard to track down.  Let&#8217;s say that you have some static content like a funny image and want to know why everyone is going to that image.  Maybe your getting <a href="http://digg.com/">Dugg</a> or <a href="http://slashdot.org">./</a> and this will help you tell (and find out what your page is so you can Digg yourself if you&#8217;re into that sort of thing).</date></sitename></p>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2007/perl/syshostname/' rel='bookmark' title='Sys::Hostname'>Sys::Hostname</a></li>
<li><a href='http://eric.lubow.org/2009/perl/cleaning-up-long-conditionals-with-grep/' rel='bookmark' title='Cleaning Up Long Conditionals With Grep'>Cleaning Up Long Conditionals With Grep</a></li>
<li><a href='http://eric.lubow.org/2009/ruby/rails/checking-roles-in-views-using-rolerequirement/' rel='bookmark' title='Checking Roles in Views Using RoleRequirement'>Checking Roles in Views Using RoleRequirement</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2008/linux-security/checking-for-a-dos/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache mod_proxy</title>
		<link>http://eric.lubow.org/2008/system-administration/apache-system-administration/apache-mod_proxy/</link>
		<comments>http://eric.lubow.org/2008/system-administration/apache-system-administration/apache-mod_proxy/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 14:00:10 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://eric.lubow.org/?p=65</guid>
		<description><![CDATA[I came up against the interesting problem of putting multiple stand alone apache tomcat instances with different virtual host names on the same machine that all needed to be accessible via port 80 (on the same IP). There is always mod_jk, but that seems like a bit too much to fix a simple problem. Being [...]]]></description>
			<content:encoded><![CDATA[<p>I came up against the interesting problem of putting multiple stand alone apache tomcat instances with different virtual host names on the same machine that all needed to be accessible via port 80 (on the same IP).  There is always mod_jk, but that seems like a bit too much to fix a simple problem.  Being a strong believer in the right tool for the right job, I came across mod_proxy.  This way I get to take advantage of apache connection handling without having to put a whole proxy server in front of it.  Because there is dispatching by virtual host to do, putting apache in front just seemed to be the best idea.</p>
<p>Since there aren&#8217;t too many clear HOWTOs on this, it took a bit of fudging.  Here is what you need to know.</p>
<p>Let&#8217;s create the host <em>http://port8080.lubow.org/</em> to go to <em>http://8080.lubow.org:8080/</em>.  </p>
<p>The first thing is a fairly common default configuration of <strong>NameVirtualHost</strong> option.  This is so you can have multiple virtual hosts per IP.  Unless you are crazy (or have a really good reason), you do not want to create an open proxy.  So you need to globally configure the <strong>ProxyRequests</strong> variable to be off.  Do the base setup for a VirtualHost of <strong>ServerName</strong> and <strong>ServerAdmin</strong>.</p>
<p>Setup the proxy authorizations (similar to the apache allow/denys).  In order for the right HTTP headers to make it to the proxy&#8217;d virtual host, the headers will need to be rewritten.  This needs to happen both going to the host and coming back from the host going to the client.  This is why there is the <strong>ProxyPass</strong> and <strong>ProxyPassReverse</strong>.  The first argument is the URL that on the virtual host that should match the URL (second argument) on the proxy&#8217;d virtual host.  The <strong><a href="http://httpd.apache.org/docs/2.2/mod/mod_proxy.html#proxypreservehost">ProxyPreserveHost</a></strong> option is generally not needed (but it is for the specific application I am running.  Click the link above to read the description to determine whether it is right for you.</p>
<p>Putting it all together, you will get a file that looks like below.  Make sure you replace your IPs and hostnames with what&#8217;s appropriate for your environment.</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00007f;">ProxyRequests</span> <span style="color: #0000ff;">Off</span><br />
<span style="color: #00007f;">NameVirtualHost</span> 1.2.3.4:<span style="color: #ff0000;">80</span><br />
<br />
&lt;<span style="color: #000000; font-weight:bold;">virtualhost</span> 1.2.3.4:<span style="color: #ff0000;">80</span>&gt;<br />
&nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ServerAdmin</span> webmaster@lubow.org<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ServerName</span> port8080.lubow.org<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;<span style="color: #000000; font-weight:bold;">proxy</span> *&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;/<span style="color: #000000; font-weight:bold;">proxy</span>&gt;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ProxyPreserveHost</span> &nbsp; <span style="color: #0000ff;">On</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ProxyPass</span> &nbsp; / http://<span style="color: #ff0000;">8080</span>.lubow.org:<span style="color: #ff0000;">8080</span>/<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">ProxyPassReverse</span> &nbsp; &nbsp;/ http://<span style="color: #ff0000;">8080</span>.lubow.org:<span style="color: #ff0000;">8080</span>/<br />
&lt;/<span style="color: #000000; font-weight:bold;">virtualhost</span>&gt;</div></div>


<p>Related posts:<ol><li><a href='http://eric.lubow.org/2007/system-administration/a-few-apache-tips/' rel='bookmark' title='A Few Apache Tips'>A Few Apache Tips</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://eric.lubow.org/2008/system-administration/apache-system-administration/apache-mod_proxy/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

