<?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>MagicalTux in Japan &#187; Apache</title>
	<atom:link href="http://blog.magicaltux.net/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.magicaltux.net</link>
	<description>Geekness brought me to Japan!</description>
	<lastBuildDate>Mon, 26 Jul 2010 21:31:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Doing the impossible with apache modules</title>
		<link>http://blog.magicaltux.net/2010/01/15/doing-the-impossible-with-apache-modules/</link>
		<comments>http://blog.magicaltux.net/2010/01/15/doing-the-impossible-with-apache-modules/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 07:42:35 +0000</pubDate>
		<dc:creator>MagicalTux</dc:creator>
				<category><![CDATA[Geek Attitude]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Apache module]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Dev]]></category>

		<guid isPermaLink="false">http://blog.magicaltux.net/?p=416</guid>
		<description><![CDATA[I&#8217;ve been fighting with apache during the past few days to try to accomplish something that has never been done until now. Apache has some nice included modules, for example mod_vhost_alias. This module allows someone to configure vhosts by just creating directories however it has some limitations: It will cause problems with some other modules [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been fighting with apache during the past few days to try to accomplish something that has never been done until now.</p>
<p>Apache has some nice included modules, for example mod_vhost_alias. This module allows someone to configure vhosts by just creating directories however it has some limitations:</p>
<ul>
<li>It will cause problems with some other modules like mod_rewrite</li>
<li>You can&#8217;t configure stuff (php options, etc) by host (only with .htaccess files, but you can&#8217;t alter all settings)</li>
<li>It can&#8217;t handle variable kinds of domains</li>
</ul>
<p>I decided to do something better, even with the people on #apache-modules (freenode) saying it&#8217;s not possible. It was even no possible to do this cleanly, however looking in apache&#8217;s code allowed me to reach my goal without too many problems, but with some really dirty parts.</p>
<h2>#define CORE_PRIVATE</h2>
<p>To reach my goal I needed to use some functions from Apache2&#8242;s core. I just wanted to say that I am really sorry, and won&#8217;t do it again (maybe). The functions I used are not meant to be used the way I used them, however I had no choice has there is no publicly available function to change the document root, or to inject configuration directives in the current request.</p>
<p>Anyway don&#8217;t do this at home, kids!</p>
<h2>ap_get_module_config(&#8230;, &amp;core_module)</h2>
<p>One of the keys to play with core config dynamically is to fetch it. This is the way to modify ap_document_root. I just return DECLINED after completing my dirty work to let apache think it still has to do its work. Yes this is dirty. But it works.</p>
<h2>ap_walk_config()</h2>
<p>Ever wanted to do bad things in a per-config context? Now you can. I won&#8217;t comment this too much, but I&#8217;ll just say that it saved me big time (this one is not part of CORE_PRIVATE, so you can use it freely I guess).</p>
<p>The final step was to make logging easier. I decided to throw all the logging info through a udg socket which is then collected by a daemon, stored locally, and transferred to the logging server at the same time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.magicaltux.net/2010/01/15/doing-the-impossible-with-apache-modules/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
