<?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>Racker Hacker &#187; apache</title>
	<atom:link href="http://rackerhacker.com/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://rackerhacker.com</link>
	<description>Words of wisdom from a server administrator</description>
	<lastBuildDate>Wed, 16 May 2012 12:55:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using OpenSSL&#039;s s_client command with web servers using Server Name Indication (SNI)</title>
		<link>http://rackerhacker.com/2012/02/07/using-openssls-s_client-command-with-web-servers-using-server-name-indication-sni/</link>
		<comments>http://rackerhacker.com/2012/02/07/using-openssls-s_client-command-with-web-servers-using-server-name-indication-sni/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 14:07:41 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=2998</guid>
		<description><![CDATA[One of the handiest tools in the OpenSSL toolbox is s_client. You can quickly view lots of details about the SSL certificates installed on a particular server and diagnose problems. For example, use this command to look at Google's SSL certificates: openssl s_client -connect encrypted.google.com:443 You'll see the chain of certificates back to the original [...]<p><a href="http://rackerhacker.com/2012/02/07/using-openssls-s_client-command-with-web-servers-using-server-name-indication-sni/">Using OpenSSL's s_client command with web servers using Server Name Indication (SNI)</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>One of the handiest tools in the OpenSSL toolbox is <code>s_client</code>.  You can quickly view lots of details about the SSL certificates installed on a particular server and diagnose problems.  For example, use this command to look at Google's SSL certificates:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">openssl s_client -connect encrypted.google.com:443</pre></div></div>

<p>You'll see the chain of certificates back to the original certificate authority where Google bought its certificate at the top, a copy of their SSL certificate in plain text in the middle, and a bunch of session-related information at the bottom.</p>
<p>This works really well when a site has one SSL certificate installed per IP address (this used to be a hard requirement).  With <a href="http://en.wikipedia.org/wiki/Server_Name_Indication">Server Name Indication</a> (SNI), a web server can have multiple SSL certificates installed on the same IP address.  SNI-capable browsers will specify the hostname of the server they're trying to reach during the initial handshake process.  This allows the web server to determine the correct SSL certificate to use for the connection.</p>
<p>If you try to connect to rackerhacker.com with <code>s_client</code>, you'll find that you receive the default SSL certificate installed on my server and not the one for this site:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">$ openssl s_client -connect rackerhacker.com:443
Certificate chain
 0 s:/C=US/ST=Texas/L=San Antonio/O=MHTX Enterprises/CN=*.mhtx.net
   i:/C=US/O=SecureTrust Corporation/CN=SecureTrust CA
 1 s:/C=US/O=SecureTrust Corporation/CN=SecureTrust CA
   i:/C=US/O=Entrust.net/OU=www.entrust.net/CPS incorp. by ref. (limits liab.)/OU=(c) 1999 Entrust.net Limited/CN=Entrust.net Secure Server Certification Authority</pre></div></div>

<p>Add on the <code>-servername</code> argument and <code>s_client</code> will do the additional SNI negotiation step for you:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">$ openssl s_client -connect rackerhacker.com:443 -servername rackerhacker.com
Certificate chain
 0 s:/OU=Domain Control Validated/OU=PositiveSSL/CN=rackerhacker.com
   i:/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=PositiveSSL CA
 1 s:/C=GB/ST=Greater Manchester/L=Salford/O=Comodo CA Limited/CN=PositiveSSL CA
   i:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware
 2 s:/C=US/ST=UT/L=Salt Lake City/O=The USERTRUST Network/OU=http://www.usertrust.com/CN=UTN-USERFirst-Hardware
   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
 3 s:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root
   i:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root</pre></div></div>

<p>You may be asking yourself this question:</p>
<blockquote><p>Why doesn't the web server just use the <code>Host:</code> header that my browser sends already to figure out which SSL certificate to use?</p></blockquote>
<p>Keep in mind that the SSL negotiation must occur <b>prior</b> to sending the HTTP request through to the remote server.  That means that the browser and the server have to do the certificate exchange earlier in the process and the browser wouldn't get the opportunity to specify which site it's trying to reach.  SNI fixes that by allowing a <code>Host:</code> header type of exchange during the SSL negotiation process.</p>
<p><a href="http://rackerhacker.com/2012/02/07/using-openssls-s_client-command-with-web-servers-using-server-name-indication-sni/">Using OpenSSL's s_client command with web servers using Server Name Indication (SNI)</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2012/02/07/using-openssls-s_client-command-with-web-servers-using-server-name-indication-sni/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenStack bleeding-edge Python packages are now available</title>
		<link>http://rackerhacker.com/2012/02/01/openstack-bleeding-edge-python-packages-are-now-available/</link>
		<comments>http://rackerhacker.com/2012/02/01/openstack-bleeding-edge-python-packages-are-now-available/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 15:05:16 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[openstack]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=2890</guid>
		<description><![CDATA[I sometimes enjoy living on the edge occasionally and that sometimes means I keep up with OpenStack changes commit by commit. If you're in the same boat as I am, you may save some time by using my repository of bleeding-edge Python packages from the OpenStack projects: pypi.mhtx.net Python packages are updated moments after the [...]<p><a href="http://rackerhacker.com/2012/02/01/openstack-bleeding-edge-python-packages-are-now-available/">OpenStack bleeding-edge Python packages are now available</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>I sometimes enjoy living on the edge occasionally and that sometimes means I keep up with OpenStack changes commit by commit.  If you're in the same boat as I am, you may save some time by using my repository of bleeding-edge Python packages from the OpenStack projects:</p>
<ul>
<li><a href="http://pypi.mhtx.net/">pypi.mhtx.net</a></li>
</ul>
<p>Python packages are updated moments after the commit is merged into the repositories under <a href="http://github.com/openstack">OpenStack's github account</a>.  </p>
<p>Although the packages will contain the latest code available, rest assured that the code has passed an initial code review (by humans), unit tests, and varying levels of functional or integrated testing.  There may still be a bug or two cropping up after that, so be aware of that as you utilize these packages.</p>
<p>The package versions utilize a standard format:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">[package]-[version]-[git commit count]-[short commit hash]</pre></div></div>

<p>If you need to check the git log up to that particular commit, just run <code>git log</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">git log [short commit hash]</pre></div></div>

<p>Instructions for configuring <code>pip</code> or <code>easy_install</code> are provided <a href="http://pypi.mhtx.net/">within the repository</a>.</p>
<p>In addition, the repository is accessible via IPv4 and IPv6.</p>
<p><a href="http://rackerhacker.com/2012/02/01/openstack-bleeding-edge-python-packages-are-now-available/">OpenStack bleeding-edge Python packages are now available</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2012/02/01/openstack-bleeding-edge-python-packages-are-now-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a local PyPi repository using only mod_rewrite</title>
		<link>http://rackerhacker.com/2012/01/31/create-a-local-pypi-repository-using-only-mod_rewrite/</link>
		<comments>http://rackerhacker.com/2012/01/31/create-a-local-pypi-repository-using-only-mod_rewrite/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 04:02:49 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=2861</guid>
		<description><![CDATA[Regular users of Python's package tools like pip or easy_install are probably familiar with the PyPi repository. It's a one-stop-shop to learn more about available Python packages and get them installed on your server. However, certain folks may find the need to host a local PyPi repository for their own packages. You may need it [...]<p><a href="http://rackerhacker.com/2012/01/31/create-a-local-pypi-repository-using-only-mod_rewrite/">Create a local PyPi repository using only mod_rewrite</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Regular users of Python's package tools like <a href="http://pypi.python.org/pypi/pip">pip</a> or <a href="http://pypi.python.org/pypi/setuptools">easy_install</a> are probably familiar with the <a href="http://pypi.python.org/pypi">PyPi</a> repository.  It's a one-stop-shop to learn more about available Python packages and get them installed on your server.</p>
<p>However, certain folks may find the need to host a local PyPi repository for their own packages.  You may need it to store Python code which you don't plan to release publicly or you may need to add proprietary patches to upstream Python packages.  Regardless of the reason to have it, a local PyPi repository is relatively easy to configure.</p>
<p>You'll need to start with a base directory for your PyPi repository.  For this example, I chose <code>/var/pypi</code>.  The directory structure should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">/var/pypi/simple/[package_name]/[package_tarball]</pre></div></div>

<p>For a package like <code>pip</code>, you'd make a structure like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">/var/pypi/simple/pip/pip-1.0.2.tar.gz</pre></div></div>

<p>Once you have at least one package stored locally, it's time to configure apache.  Here's a snippet from the virtual host I configured:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">DocumentRoot /var/pypi/
ServerName pypi.example.com
&nbsp;
Options +Indexes
&nbsp;
RewriteEngine On
RewriteRule ^/robots.txt - [L]
RewriteRule ^/icons/.* - [L]
RewriteRule ^/index\..* - [L]
&nbsp;
RewriteCond /var/pypi/$1 !-f
RewriteCond /var/pypi/$1 !-d
RewriteRule ^/(.*)/?$ http://pypi.python.org/$1 [R,L]</pre></div></div>

<p>The last set of rewrite directives check to see if the request refers to an existing file or directory under your document root.  If it does, your server will reply with a directory listing or with the actual file to download.  If the directory or file doesn't exist, apache will send the client a redirection to the main PyPi site.</p>
<p>Reload your apache configuration to bring in your new changes.  Let's try to download the <code>pip</code> tarball from our local server in the example I mentioned above:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">$ curl -I http://pypi.example.com/simple/pip/
HTTP/1.1 200 OK
&nbsp;
$ curl -I http://pypi.example.com/simple/pip/pip-1.0.2.tar.gz
HTTP/1.1 200 OK</pre></div></div>

<p>I've obviously snipped a bit of the response above, but you can see that apache is responding with 200's since it has the directories and files that I was trying to retrieve via curl.  Let's try to get something we don't have locally, like <code>kombu</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">$ curl -I http://pypi.example.com/simple/kombu/
HTTP/1.1 302 Found
Location: http://pypi.python.org/simple/kombu/</pre></div></div>

<p>Our local PyPi repository doesn't have <code>kombu</code> so it will refer our Python tools over to the official PyPi repository to get the listing of available package versions for <code>kombu</code>.</p>
<p>Now we need to tell <code>pip</code> to use our local repository.  Edit <code>~/.pip/pip.conf</code> and add:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">[global]
index-url = http://pypi.example.com/simple/</pre></div></div>

<p>If you'd rather use <code>easy_install</code>, edit <code>~/.pydistutils.cfg</code> and add:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">[easy_install]
index_url = http://pypi.example.com/simple/</pre></div></div>

<p>Once your tools are configured, try installing a package you have locally and try to install one that you know you won't have locally.  You can add <code>-v</code> to <code>pip install</code> to watch it retrieve different URL's to get the packages it needs.  If you spot any peculiar behavior or unexpected redirections, double-check your mod_rewrite rules in your apache configuration and check the spelling of your directories under your document root.</p>
<p><a href="http://rackerhacker.com/2012/01/31/create-a-local-pypi-repository-using-only-mod_rewrite/">Create a local PyPi repository using only mod_rewrite</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2012/01/31/create-a-local-pypi-repository-using-only-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting apache, PHP, and memcached working with SELinux</title>
		<link>http://rackerhacker.com/2011/09/07/getting-apache-php-and-memcached-working-with-selinux/</link>
		<comments>http://rackerhacker.com/2011/09/07/getting-apache-php-and-memcached-working-with-selinux/#comments</comments>
		<pubDate>Thu, 08 Sep 2011 03:55:00 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[memcached]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[red hat]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[selinux]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=2516</guid>
		<description><![CDATA[I'm using SELinux more often now on my Fedora 15 installations and I came up against a peculiar issue today on a new server. My PHP installation is configured to store its sessions in memcached and I brought over some working configurations from another server. However, each time I accessed a page which tried to [...]<p><a href="http://rackerhacker.com/2011/09/07/getting-apache-php-and-memcached-working-with-selinux/">Getting apache, PHP, and memcached working with SELinux</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p><a href="http://rackerhacker.com/wp-content/uploads/2011/09/selinux-penguin-125.png"><img src="http://rackerhacker.com/wp-content/uploads/2011/09/selinux-penguin-125.png" alt="SELinux Penguin" title="SELinux Penguin" width="125" height="113" class="alignright size-full wp-image-2532" /></a>I'm using SELinux more often now on my Fedora 15 installations and I came up against a peculiar issue today on a new server.  My PHP installation is configured to store its sessions in memcached and I brought over some working configurations from another server.  However, each time I accessed a page which tried to initiate a session, the page load would hang for about a minute and I'd find this in my apache error logs:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">[Thu Sep 08 03:23:40 2011] [error] [client 11.22.33.44] PHP Warning:  
Unknown: Failed to write session data (memcached). Please verify that 
the current setting of session.save_path is correct (127.0.0.1:11211) 
in Unknown on line 0</pre></div></div>

<p>I ran through my usual list of checks:</p>
<ul>
<li>netstat showed memcached bound to the correct ports/interfaces</li>
<li>memcached was running and I could reach it via telnet</li>
<li>memcached-tool could connect and pull stats from memcached</li>
<li>double-checked my php.ini</li>
<li>tested memcached connectivity via a PHP and ruby script -- they worked</li>
</ul>
<p>Even after all that, I still couldn't figure out what was wrong.  I ran strace on memcached while I ran a curl against the page which creates a session and I found something significant -- memcached wasn't seeing any connections whatsoever at that time.  A quick check of the lo interface with tcpdump showed the same result.  Just before I threw a chair, I remembered one thing:</p>
<p><em>SELinux.</em></p>
<p>A quick check for AVC denials showed the problem:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># aureport --avc | tail -n 1
4021. 09/08/2011 03:23:38 httpd system_u:system_r:httpd_t:s0 42 tcp_socket name_connect system_u:object_r:memcache_port_t:s0 denied 31536</pre></div></div>

<p>I'm far from being a guru on SELinux, so I leaned on audit2allow for help:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># grep memcache /var/log/audit/audit.log | audit2allow
&nbsp;
#============= httpd_t ==============
#!!!! This avc can be allowed using one of the these booleans:
#     httpd_can_network_relay, httpd_can_network_memcache, httpd_can_network_connect
&nbsp;
allow httpd_t memcache_port_t:tcp_socket name_connect;</pre></div></div>

<p>The boolean we're looking for is <code>httpd_can_network_memcache</code>. Flipping the boolean can be done in a snap:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># setsebool -P httpd_can_network_memcache 1
# getsebool httpd_can_network_memcache
httpd_can_network_memcache --&gt; on</pre></div></div>

<p>After adjusting the boolean, apache was able to make connections to memcached without a hitch.  My page which created sessions loaded quickly and I could see data being stored in memcached.  If you want to check the status of all of the apache-related SELinux booleans, just use getsebool:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># getsebool -a | grep httpd | grep off$
allow_httpd_anon_write --&gt; off
allow_httpd_mod_auth_ntlm_winbind --&gt; off
allow_httpd_mod_auth_pam --&gt; off
allow_httpd_sys_script_anon_write --&gt; off
httpd_can_check_spam --&gt; off
httpd_can_network_connect_cobbler --&gt; off
httpd_can_network_connect_db --&gt; off
httpd_can_network_relay --&gt; off
httpd_can_sendmail --&gt; off
httpd_dbus_avahi --&gt; off
httpd_enable_ftp_server --&gt; off
httpd_enable_homedirs --&gt; off
httpd_execmem --&gt; off
httpd_read_user_content --&gt; off
httpd_setrlimit --&gt; off
httpd_ssi_exec --&gt; off
httpd_tmp_exec --&gt; off
httpd_unified --&gt; off
httpd_use_cifs --&gt; off
httpd_use_gpg --&gt; off
httpd_use_nfs --&gt; off</pre></div></div>

<p>If you're interested in SELinux, a good way to get your feet wet is to head over to the CentOS Wiki and review their <a href="http://wiki.centos.org/HowTos/SELinux">SELinux Howtos</a></p>
<p><a href="http://rackerhacker.com/2011/09/07/getting-apache-php-and-memcached-working-with-selinux/">Getting apache, PHP, and memcached working with SELinux</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2011/09/07/getting-apache-php-and-memcached-working-with-selinux/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Throwing thoughtful &quot;403 Forbidden&quot; responses with apache</title>
		<link>http://rackerhacker.com/2010/11/17/throwing-thoughtful-403-forbidden-responses-with-apache/</link>
		<comments>http://rackerhacker.com/2010/11/17/throwing-thoughtful-403-forbidden-responses-with-apache/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 13:47:19 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=1936</guid>
		<description><![CDATA[If you offer a web service that users query via scripts or other applications, you'll probably find that some people will begin to abuse the service. My icanhazip.com site is no exception. While many of the users have reasonable usage patterns, there are some users that query the site more than once per second from [...]<p><a href="http://rackerhacker.com/2010/11/17/throwing-thoughtful-403-forbidden-responses-with-apache/">Throwing thoughtful "403 Forbidden" responses with apache</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>If you offer a web service that users query via scripts or other applications, you'll probably find that some people will begin to abuse the service.  My <a href="http://icanhazip.com/">icanhazip.com</a> site is no exception.</p>
<p>While many of the users have reasonable usage patterns, there are some users that query the site more than once per second from the same IP address.  If you haven't used the site before, all it does is return your public IP address in plain text.  Unless your IP changes rapidly, you may not need to query the site more than a few times an hour.</p>
<p>I added the following to my icanhazip.com virtual host definition to get the message across to those users that abuse the service:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">ErrorDocument</span> <span style="color: #ff0000;">403</span> <span style="color: #7f007f;">&quot;No can haz IP. Stop abusing this service. <span style="color: #000099; font-weight: bold;">\</span>
    Contact major at mhtx dot net for details.&quot;</span>
<span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">On</span>
<span style="color: #00007f;">RewriteCond</span> %{REMOTE_ADDR} ^12.23.34.45$ [OR]
<span style="color: #00007f;">RewriteCond</span> %{REMOTE_ADDR} ^98.87.76.65$
<span style="color: #00007f;">RewriteRule</span> .* nocanhaz [F]</pre></div></div>

<p>The users that are caught on the business end of these 403 responses will see something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">$ curl -i icanhazip.com
HTTP/1.1 403 Forbidden
Date: Wed, 17 Nov 2010 13:42:55 GMT
Server: Apache
Content-Length: 84
Connection: close
Content-Type: text/html; charset=iso-8859-1
&nbsp;
No can haz IP. Stop abusing this service. Contact major at mhtx dot net for details.</pre></div></div>

<p><a href="http://rackerhacker.com/2010/11/17/throwing-thoughtful-403-forbidden-responses-with-apache/">Throwing thoughtful "403 Forbidden" responses with apache</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2010/11/17/throwing-thoughtful-403-forbidden-responses-with-apache/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>A simple guide to redundant cloud hosting</title>
		<link>http://rackerhacker.com/2010/08/17/a-simple-guide-to-redundant-cloud-hosting/</link>
		<comments>http://rackerhacker.com/2010/08/17/a-simple-guide-to-redundant-cloud-hosting/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 00:41:16 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cloud servers]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[high availability]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[load balancing]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[rackspace]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[slicehost]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=1771</guid>
		<description><![CDATA[Today, on my 28th birthday, I'm finally delivering on a promise to my readers which I made about two months ago. I've written a guide on how to host a web application redundantly in a cloud environment. While it's still a bit of a rough draft, it should be a good starting point for those [...]<p><a href="http://rackerhacker.com/2010/08/17/a-simple-guide-to-redundant-cloud-hosting/">A simple guide to redundant cloud hosting</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Today, on my 28th birthday, I'm finally delivering on a promise to my readers which I made about two months ago.  I've <a href="/redundant-cloud-hosting-configuration-guide/">written a guide</a> on how to host a web application redundantly in a cloud environment.  While it's still a bit of a rough draft, it should be a good starting point for those who haven't worked in virtualized environments before.  Also, it may show some of the more experienced systems administrators a new way to do things.</p>
<p>The guide: <a href="/redundant-cloud-hosting-configuration-guide/">Redundant Cloud Hosting Guide</a></p>
<p>As always, if you find anything in the guide that needs improvement, I'm all ears. <img src='http://rackerhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://rackerhacker.com/2010/08/17/a-simple-guide-to-redundant-cloud-hosting/">A simple guide to redundant cloud hosting</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2010/08/17/a-simple-guide-to-redundant-cloud-hosting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Private network interfaces: the forgotten security hole</title>
		<link>http://rackerhacker.com/2010/03/01/private-network-interfaces-the-forgotten-security-hole/</link>
		<comments>http://rackerhacker.com/2010/03/01/private-network-interfaces-the-forgotten-security-hole/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 00:55:07 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[encryption]]></category>
		<category><![CDATA[iptables]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[tcpwrappers]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=1263</guid>
		<description><![CDATA[Regardless of the type of hosting you're using - dedicated or cloud - it's important to take network interface security seriously. Most often, threats from the internet are the only ones mentioned. However, if you share a private network with other customers, you have just as much risk on that interface. Many cloud providers allow [...]<p><a href="http://rackerhacker.com/2010/03/01/private-network-interfaces-the-forgotten-security-hole/">Private network interfaces: the forgotten security hole</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Regardless of the type of hosting you're using - dedicated or cloud - it's important to take network interface security seriously.  Most often, threats from the internet are the only ones mentioned.  However, if you share a private network with other customers, you have just as much risk on that interface.</p>
<p>Many cloud providers allow you access to a private network environment where you can exchange data with other instances or other services offered by the provider.  The convenience of this access comes with a price: other instances can access your instance on the private network just as easily as they could on the public interface.</p>
<p>Here are some security tips for your private interfaces:</p>
<p><strong>Disable the private interface</strong><br />
This one is pretty simple.  If you have only one instance or server, and you don't need to communicate privately with any other instances, just disable the interface.  Remember to configure your networking scripts to leave the interface disabled after reboots.</p>
<p><strong>Use packet filtering</strong><br />
The actual mechanism will vary based on your operating system, but filtering packets is the one of the simplest ways to secure your private interface.  You can take some different approaches with them, but I find the easiest method is to allow access from your other instances and reject all other traffic.</p>
<p>For additional security, you can limit access based on ports as well as source IP addresses.  This could prevent an attacker from having easy access to your other instances if they're able to break into one of them.</p>
<p><strong>Configure your daemons to listen on the appropriate interfaces</strong><br />
If there are services that don't need to be listening on the private network, don't allow them to listen on your private interface.  For example, MySQL might need to listen on the private interface so the web server can talk to it, but apache won't need to listen on the private interface.  This reduces the profile of your instance on the private network and makes it a less likely target for attack.</p>
<p><strong>Use hosts.allow and hosts.deny</strong><br />
Many new systems administrators forget about how handy tcpwrappers can be for limiting access.  If your firewall is down in error, host.allow and hosts.deny could be an extra layer of protection.  It's important to ensure that the daemons you are attempting to control are build with tcpwrappers support.  Daemons like sshd support it, but apache and MySQL do not.</p>
<p><strong>Encrypt all traffic on the private network</strong><br />
Just because it's called a "private" network doesn't mean that your traffic can traverse the network privately.  You should always err on the side of caution and encrypt all traffic traversing the private network.  You can use ssh tunnels, stunnel, or the built-in SSL features found in most daemons.</p>
<p>This also brings up an important point: <strong>you should know how your provider's private network works</strong>.  Are there safeguards to prevent sniffing?  Could someone else possibly ARP spoof your instance's private IP addresses?  Is your private network's subnet shared among many customers?</p>
<p>With all of that said, it's also very important to have proper change control policies so that administrators working after you are fully aware of the security measures in place and why they are important.  This will ensure that all of the administrators on your instances will understand the security of the system and they should be able to make sensible adjustments later for future functionality.</p>
<p><a href="http://rackerhacker.com/2010/03/01/private-network-interfaces-the-forgotten-security-hole/">Private network interfaces: the forgotten security hole</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2010/03/01/private-network-interfaces-the-forgotten-security-hole/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A New Year System Administrator Inspiration</title>
		<link>http://rackerhacker.com/2010/01/03/a-new-year-system-administrator-inspiration/</link>
		<comments>http://rackerhacker.com/2010/01/03/a-new-year-system-administrator-inspiration/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 02:53:53 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[general advice]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[networking]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=1104</guid>
		<description><![CDATA[Happy New Year! I certainly hope it's a great one for you, your family, and your business. As the new year begins, I figured it would be a good time to sit down and answer a question that I hear very often: How do I become a better systems administrator? The best way to become [...]<p><a href="http://rackerhacker.com/2010/01/03/a-new-year-system-administrator-inspiration/">A New Year System Administrator Inspiration</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Happy New Year!  I certainly hope it's a great one for you, your family, and your business.  As the new year begins, I figured it would be a good time to sit down and answer a question that I hear very often:</p>
<p><em>How do I become a better systems administrator?</em></p>
<p>The best way to become a better systems administrator is to <strong>fully understand the theory</strong> of what's happening in your server's environment.</p>
<p>What do I mean by that?  Learn why things aren't happening as you expected and think about all of the factors that could possibly be involved.  Instead of thinking purely about cause and effect, you'll find it much easier and rewarding to consider everything inside and outside your environment before you make any changes.</p>
<p>This still may be a little difficult to fully understand, so he's an example.  Let's say you're handling an issue where a customer can't reach a website hosted on their server.  When you ask them for more details, they might give you the dreaded reply: "It's not coming up."  Start by making a mental list of the problems that are easiest to check:</p>
<ul>
<li>Is the web server daemon running?</li>
<li>If a database server is being used, is it running and accessible?</li>
<li>Is there a software/hardware firewall blocking port 80?</li>
<li>Is a script stuck on the server tying up resources?</li>
<li>Could there be a DNS resolution problem?</li>
<li>Is the server up?</li>
<li>Did a switch fail?</li>
<li>Is the server's hard disk out of space?</li>
<li>Can the customer reach other websites like Google or Yahoo?</li>
<li>If SELinux is involved, have the appropriate contexts been set?</li>
<li>Could the site be a target of a denial of service attack?</li>
<li>Has the server reached its connection tracking limit?</li>
</ul>
<p>Of course, this is a relatively short list, but these are all easy to check.  If you're thinking about cause and effect, you might only consider the web server daemon and some basic network issues.  By considering all of the other factors that may be related, you've ensured that all of the basics are covered before you consider more complex problems.</p>
<p>Most systems administrators have taken an error message and tossed it in en masse into Google before.  Occasionally, no results will appear for the search.  If you find yourself in this situation, try to understand the individual parts of the error message.  Work outward from what you know already.  You should know which daemon said it, and you may have an idea of what the application was doing when the error occurred.  Take time to consider what the daemon is trying to tell you within the context of what it was doing at the time.</p>
<p>One of the easiest ways to force yourself to be immersed into this way of thinking is to host applications for non-technical people.  You'll find that many customers want things done differently, and they're all at different levels of technical aptitude.  Some may find it a frustrating experience at first, but you'll think yourself later.  It will force you to consider all aspects of how a server operates since you might not always know what's happening within a customer's application.</p>
<p>As always, if you find yourself stumbling, remember to ask your peers and colleagues.  Even if they haven't seen the particular issue, they will probably be able to guide you closer to the solution you seek.</p>
<p><a href="http://rackerhacker.com/2010/01/03/a-new-year-system-administrator-inspiration/">A New Year System Administrator Inspiration</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2010/01/03/a-new-year-system-administrator-inspiration/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Fedora 11 httpd: alloc_listener: failed to get a socket for (null)</title>
		<link>http://rackerhacker.com/2009/08/14/fedora-11-httpd-alloc_listener-failed-to-get-a-socket-for-null/</link>
		<comments>http://rackerhacker.com/2009/08/14/fedora-11-httpd-alloc_listener-failed-to-get-a-socket-for-null/#comments</comments>
		<pubDate>Fri, 14 Aug 2009 17:14:02 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[emergency]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[yum]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=981</guid>
		<description><![CDATA[If you use Fedora 11 in a virtualized environment, you may have seen this error recently if you've updated to apr-1.3.8-1: [root@f11 ~]# /etc/init.d/httpd start Starting httpd: [Fri Aug 14 17:05:24 2009] [crit] (22)Invalid argument: alloc_listener: failed to get a socket for (null) Syntax error on line 134 of /etc/httpd/conf/httpd.conf: Listen setup failed [FAILED] The [...]<p><a href="http://rackerhacker.com/2009/08/14/fedora-11-httpd-alloc_listener-failed-to-get-a-socket-for-null/">Fedora 11 httpd: alloc_listener: failed to get a socket for (null)</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>If you use Fedora 11 in a virtualized environment, you may have seen this error recently if you've updated to apr-1.3.8-1:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">[root@f11 ~]# /etc/init.d/httpd start
Starting httpd: [Fri Aug 14 17:05:24 2009] [crit] (22)Invalid argument: alloc_listener: failed to get a socket for (null)
Syntax error on line 134 of /etc/httpd/conf/httpd.conf:
Listen setup failed
                                                           [FAILED]</pre></div></div>

<p>The issue is related to three kernel calls that are used in apr-1.3.8-1: accept4(), dup3() and epoll_create1().  Without these calls, apache is unable to start.  </p>
<p><strong><u>Update on August 17, 2009:</u> the Fedora team has <a href="https://bugzilla.redhat.com/show_bug.cgi?id=516331#c12">pushed apr-1.3.8-2 into the stable repositories</a> for Fedora 11, which eliminates the need for the temporary fix shown below.</strong></p>
<p><strong>Deprecated solution:</strong> There is a <a href="https://bugzilla.redhat.com/show_bug.cgi?id=516331">bug open</a> with the Fedora team, and there is a <a href="https://bugzilla.redhat.com/show_bug.cgi?id=516331#c10">temporary fix</a> available:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">yum --enablerepo=updates-testing update apr</pre></div></div>

<p><a href="http://rackerhacker.com/2009/08/14/fedora-11-httpd-alloc_listener-failed-to-get-a-socket-for-null/">Fedora 11 httpd: alloc_listener: failed to get a socket for (null)</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2009/08/14/fedora-11-httpd-alloc_listener-failed-to-get-a-socket-for-null/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rotating rails logs when using Phusion Passenger</title>
		<link>http://rackerhacker.com/2009/06/26/rotating-rails-logs-when-using-phusion-passenger/</link>
		<comments>http://rackerhacker.com/2009/06/26/rotating-rails-logs-when-using-phusion-passenger/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 15:09:54 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[logrotate]]></category>
		<category><![CDATA[passenger]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=944</guid>
		<description><![CDATA[I found a great post on Overstimulate about handling the rotation of rails logs when you use Phusion Passenger. Most of the data for your application should end up in the apache logs, but if your site is highly dynamic, you may end up with a giant production log if you're not careful. Toss this [...]<p><a href="http://rackerhacker.com/2009/06/26/rotating-rails-logs-when-using-phusion-passenger/">Rotating rails logs when using Phusion Passenger</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>I found a <a href="http://overstimulate.com/articles/logrotate-rails-passenger">great post</a> on <a href="http://overstimulate.com/">Overstimulate</a> about handling the rotation of rails logs when you use Phusion Passenger.  Most of the data for your application should end up in the apache logs, but if your site is highly dynamic, you may end up with a giant production log if you're not careful.</p>
<p>Toss this into /etc/logrotate.d/yourrailsapplication:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">/var/www/yourrailsapp/log/*.log {
  daily
  missingok
  rotate 30
  compress
  delaycompress
  sharedscripts
  postrotate
    touch /var/www/yourrailsapp/tmp/restart.txt
  endscript
}</pre></div></div>

<p>For a detailed explanation, <a href="http://overstimulate.com/articles/logrotate-rails-passenger">see the post</a> on <a href="http://overstimulate.com/">Overstimulate</a>.</p>
<p><a href="http://rackerhacker.com/2009/06/26/rotating-rails-logs-when-using-phusion-passenger/">Rotating rails logs when using Phusion Passenger</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2009/06/26/rotating-rails-logs-when-using-phusion-passenger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache 2.2: internal dummy connection</title>
		<link>http://rackerhacker.com/2008/09/23/apache-22-internal-dummy-connection/</link>
		<comments>http://rackerhacker.com/2008/09/23/apache-22-internal-dummy-connection/#comments</comments>
		<pubDate>Wed, 24 Sep 2008 01:42:21 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=465</guid>
		<description><![CDATA[After working with some RHEL 5 servers fairly regularly, I noticed a reduction in Apache 2.2 performance when many connections were made to the server. There were messages like these streaming into the access_log as well: 127.0.0.1 - - [21/Aug/2008:12:00:10 -0400] "GET / HTTP/1.0" 200 2269 "-" "Apache/2.2.3 (Red Hat) (internal dummy connection)" 127.0.0.1 - [...]<p><a href="http://rackerhacker.com/2008/09/23/apache-22-internal-dummy-connection/">Apache 2.2: internal dummy connection</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>After working with some RHEL 5 servers fairly regularly, I noticed a reduction in Apache 2.2 performance when many connections were made to the server.  There were messages like these streaming into the access_log as well:</p>
<p><code>127.0.0.1 - - [21/Aug/2008:12:00:10 -0400] "GET / HTTP/1.0" 200 2269 "-" "Apache/2.2.3 (Red Hat) (internal dummy connection)"<br />
127.0.0.1 - - [21/Aug/2008:12:00:11 -0400] "GET / HTTP/1.0" 200 2269 "-" "Apache/2.2.3 (Red Hat) (internal dummy connection)"<br />
127.0.0.1 - - [21/Aug/2008:12:00:13 -0400] "GET / HTTP/1.0" 200 2269 "-" "Apache/2.2.3 (Red Hat) (internal dummy connection)"<br />
127.0.0.1 - - [21/Aug/2008:12:00:14 -0400] "GET / HTTP/1.0" 200 2269 "-" "Apache/2.2.3 (Red Hat) (internal dummy connection)"<br />
127.0.0.1 - - [21/Aug/2008:12:00:15 -0400] "GET / HTTP/1.0" 200 2269 "-" "Apache/2.2.3 (Red Hat) (internal dummy connection)"</code></p>
<p>On servers with ipv6 enabled, you might see a line like this one:</p>
<p><code>::1 - - [21/Aug/2008:12:00:15 -0400] "GET / HTTP/1.0" 200 2269 "-" "Apache/2.2.3 (Red Hat) (internal dummy connection)"</code></p>
<p>I began to wonder why Apache was making these connections back onto itself and initiating a <code>GET /</code>.  Apache's <a href="http://wiki.apache.org/httpd/InternalDummyConnection">documentation</a> had the following:</p>
<blockquote><p>When the Apache HTTP Server manages its child processes, it needs a way to wake up processes that are listening for new connections. To do this, it sends a simple HTTP request back to itself. This request will appear in the access_log file with the remote address set to the loop-back interface (typically 127.0.0.1 or ::1 if IPv6 is configured). If you log the User-Agent string (as in the combined log format), you will see the server signature followed by "(internal dummy connection)" on non-SSL servers. During certain periods you may see up to one such request for each httpd child process.</p>
<p>These requests are perfectly normal and you do not, in general, need to worry about them. They can simply be ignored.</p></blockquote>
<p>Sure, I could easily ignore the requests, but the requests were increasing the load on my server more than I liked.  Apache's documentation suggested omitting the lines from the logs by adding the following to the Apache configuration:</p>
<p><code>SetEnvIf Remote_Addr "127\.0\.0\.1" loopback</code></p>
<p>And then adding <code>env=!loopback</code> to your <code>CustomLog</code> lines ensures that the data won't show up in your access logs.  However, you'll still end up with <code>Directory index forbidden by Options directive: /var/www/html/</code> filling up your error_logs.  A quick search revealed a <a href="http://www.inventivelabs.com.au/weblog/post/apache-s-internal-dummy-connection">handy mod_rewrite</a> rule to get rid of these requests as quickly as possible with the lowest effort required from Apache:</p>
<p><code>RewriteCond %{HTTP_USER_AGENT} ^.*internal\ dummy\ connection.*$ [NC]<br />
RewriteRule .* - [F,L]</code></p>
<p>At this point, the requests to the localhost should receive a 403 immediately.  Since you can't keep Apache from sending all of these requests to itself, the best you can do is respond to them in a manner that requires the lowest possible resources.</p>
<p><a href="http://rackerhacker.com/2008/09/23/apache-22-internal-dummy-connection/">Apache 2.2: internal dummy connection</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2008/09/23/apache-22-internal-dummy-connection/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Compress your web content for better performance</title>
		<link>http://rackerhacker.com/2008/09/19/compress-your-web-content-for-better-performance/</link>
		<comments>http://rackerhacker.com/2008/09/19/compress-your-web-content-for-better-performance/#comments</comments>
		<pubDate>Fri, 19 Sep 2008 17:00:47 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=479</guid>
		<description><![CDATA[Most web developers expend a lot of energy optimizing queries, reducing the overhead of functions, and streamlining their application's overall flow. However, many forget that one of the simplest adjustments is the compression of data as it leaves the web server. Luckily, mod_deflate makes this easy, and the Apache documentation has a handy initial configuration [...]<p><a href="http://rackerhacker.com/2008/09/19/compress-your-web-content-for-better-performance/">Compress your web content for better performance</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Most web developers expend a lot of energy optimizing queries, reducing the overhead of functions, and streamlining their application's overall flow.  However, many forget that one of the simplest adjustments is the compression of data as it leaves the web server.</p>
<p>Luckily, <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html">mod_deflate</a> makes this easy, and the Apache documentation has a <a href="http://httpd.apache.org/docs/2.0/mod/mod_deflate.html#recommended">handy initial configuration</a> available:</p>
<p><code>&lt;Location /&gt;<br />
SetOutputFilter DEFLATE<br />
BrowserMatch ^Mozilla/4 gzip-only-text/html<br />
BrowserMatch ^Mozilla/4\.0[678] no-gzip<br />
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html<br />
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary<br />
Header append Vary User-Agent env=!dont-vary<br />
&lt;/Location&gt;</code></p>
<p>This configuration will compress everything except for images.  Of course, you can't test this with curl, but you can test it with Firefox and <a href="https://addons.mozilla.org/en-US/firefox/addon/3829">LiveHTTPHeaders</a>.  If you don't have Firefox handy, you can try a very handy <a href="http://www.gidnetwork.com/tools/gzip-test.php">web application</a> that will give you the statistics about the compression of your site's data.</p>
<p><a href="http://rackerhacker.com/2008/09/19/compress-your-web-content-for-better-performance/">Compress your web content for better performance</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2008/09/19/compress-your-web-content-for-better-performance/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Change the default Apache character set</title>
		<link>http://rackerhacker.com/2007/11/15/change-the-default-apache-character-set/</link>
		<comments>http://rackerhacker.com/2007/11/15/change-the-default-apache-character-set/#comments</comments>
		<pubDate>Thu, 15 Nov 2007 18:09:01 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/2007/11/15/change-the-default-apache-character-set/</guid>
		<description><![CDATA[By default, Red Hat Enterprise Linux 4 sets the default character set in Apache to UTF-8. Your specific web application may need for the character set to be set to a different value, and the change can be made fairly easily. Here's an example where the character set is changed to ISO-8859-1: First, adjust the [...]<p><a href="http://rackerhacker.com/2007/11/15/change-the-default-apache-character-set/">Change the default Apache character set</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>By default, Red Hat Enterprise Linux 4 sets the default character set in Apache to UTF-8.  Your specific web application may need for the character set to be set to a different value, and the change can be made fairly easily.  Here's an example where the character set is changed to ISO-8859-1:</p>
<p>First, adjust the AddDefaultCharset directive in /etc/httpd/conf/httpd.conf:</p>
<p><code>#AddDefaultCharset UTF-8<br />
AddDefaultCharset ISO-8859-1</code></p>
<p>Then, reload Apache and check your headers:</p>
<p><code># /etc/init.d/httpd reload<br />
# curl -I localhost<br />
HTTP/1.1 403 Forbidden<br />
Date: Thu, 08 Nov 2007 22:18:14 GMT<br />
Server: Apache/2.0.52 (Red Hat)<br />
Accept-Ranges: bytes<br />
Content-Length: 3985<br />
Connection: close<br />
Content-Type: text/html; charset=ISO-8859-1</code></p>
<p><em>This was tested on Red Hat Enterprise Linux 4 Update 5</em></p>
<p><a href="http://rackerhacker.com/2007/11/15/change-the-default-apache-character-set/">Change the default Apache character set</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2007/11/15/change-the-default-apache-character-set/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Apache: No space left on device: Couldn&#039;t create accept lock</title>
		<link>http://rackerhacker.com/2007/08/24/apache-no-space-left-on-device-couldnt-create-accept-lock/</link>
		<comments>http://rackerhacker.com/2007/08/24/apache-no-space-left-on-device-couldnt-create-accept-lock/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 21:55:30 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[emergency]]></category>
		<category><![CDATA[quotas]]></category>
		<category><![CDATA[semaphore]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/2007/08/24/apache-no-space-left-on-device-couldnt-create-accept-lock/</guid>
		<description><![CDATA[This error completely stumped me a couple of weeks ago. Apparently someone was adjusting the Apache configuration, then they checked their syntax and attempted to restart Apache. It went down without a problem, but it refused to start properly, and didn't bind to any ports. Within the Apache error logs, this message appeared over and [...]<p><a href="http://rackerhacker.com/2007/08/24/apache-no-space-left-on-device-couldnt-create-accept-lock/">Apache: No space left on device: Couldn't create accept lock</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>This error completely stumped me a couple of weeks ago.  Apparently someone was adjusting the Apache configuration, then they checked their syntax and attempted to restart Apache.  It went down without a problem, but it refused to start properly, and didn't bind to any ports.</p>
<p>Within the Apache error logs, this message appeared over and over:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">[emerg] (28)No space left on device: Couldn't create accept lock</pre></div></div>

<p>Apache is basically saying "I want to start, but I need to write some things down before I can start, and I have nowhere to write them!"  If this happens to you, check these items in order:</p>
<p><strong>1. Check your disk space</strong><br />
This comes first because it's the easiest to check, and sometimes the quickest to fix.  If you're out of disk space, then you need to fix that problem. <img src='http://rackerhacker.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>2. Review filesystem quotas</strong><br />
If your filesystem uses quotas, you might be reaching a quota limit rather than a disk space limit.  Use <code>repquota /</code> to review your quotas on the root partition.  If you're at the limit, raise your quota or clear up some disk space.  Apache logs are usually the culprit in these situations.</p>
<p><strong>3. Clear out your active semaphores</strong><br />
Semaphores?  What the heck is a semaphore?  Well, it's actually an <a href="http://en.wikipedia.org/wiki/Semaphore">apparatus for conveying information by means of visual signals</a>.  But, when it comes to programming, <a href="http://en.wikipedia.org/wiki/Semaphore_%28programming%29">semaphores are used for communicating between the active processes of a certain application</a>.  In the case of Apache, they're used to communicate between the parent and child processes.  If Apache can't write these things down, then it can't communicate properly with all of the processes it starts.</p>
<p>I'd assume if you're reading this article, Apache has stopped running.  Run this command as root:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># ipcs -s</pre></div></div>

<p>If you see a list of semaphores, Apache has not cleaned up after itself, and some semaphores are stuck.  Clear them out with this command:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;"># for i in `ipcs -s | awk '/httpd/ {print $2}'`; do (ipcrm -s $i); done</pre></div></div>

<p>Now, in almost all cases, Apache should start properly.  If it doesn't, you may just be completely out of available semaphores.  You may want to increase your available semaphores, and you'll need to tickle your kernel to do so.  Add this to /etc/sysctl.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">kernel.msgmni = 1024
kernel.sem = 250 256000 32 1024</pre></div></div>

<p>And then run <code>sysctl -p</code> to pick up the new changes.</p>
<p>Further reading:<br />
<a href="http://en.wikipedia.org/wiki/Semaphore_%28programming%29">Wikipedia: Semaphore (Programming)</a><br />
<a href="http://www.webpipe.net/howto/Apache_accept_lock_fix">Apache accept lock fix</a></p>
<p><a href="http://rackerhacker.com/2007/08/24/apache-no-space-left-on-device-couldnt-create-accept-lock/">Apache: No space left on device: Couldn't create accept lock</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2007/08/24/apache-no-space-left-on-device-couldnt-create-accept-lock/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

