<?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>BigSmoke &#187; Apache</title>
	<atom:link href="http://blog.bigsmoke.us/tag/apache/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.bigsmoke.us</link>
	<description>Smokes your problems, coughs fresh air.</description>
	<lastBuildDate>Sat, 04 Feb 2012 18:03:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Safari: don&#8217;t give gzipped content a .gz extension</title>
		<link>http://blog.bigsmoke.us/2012/01/16/safari-ignores-content-type-for-gz-suffix</link>
		<comments>http://blog.bigsmoke.us/2012/01/16/safari-ignores-content-type-for-gz-suffix#comments</comments>
		<pubDate>Sun, 15 Jan 2012 22:39:13 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Make]]></category>
		<category><![CDATA[payformystay.com]]></category>
		<category><![CDATA[Safari]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=2021</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>Yesterday, while helping Caloe with the website for her company <a href="http://www.debuitenkok.nl/">De Buitenkok</a>, I came across the mother of all stupid bugs in Safari . Me having recently announced <a href="http://www.payformystay.com/">payformystay.com</a>, I loaded it up in Apple&#8217;s hipster browser only to notice that the CSS wasn&#8217;t loaded. Oops!</p>
<p>Reloading didn&#8217;t help, but … going over to the development version, everything loaded just fine. Conclusion? My recent optimizations—concatenating + gzipping all javascript and css—somehow fucked up payformystay for Safari users. The 14 Safari visitors (16.28% of our small group of alpha users) I received since the sixth must have gotten a pretty bleak image of the technical abilities of payformystay.com&#8217;s Chief Technician (me). <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_cry.gif' alt=':cry:' class='wp-smiley' /> </p>
<h2>The old <tt>cat | gzip</tt></h2>
<p>So, what happened?</p>
<p>To reduce the number of HTTP requests per page for all the JavaScript/CSS stuff (especially when none of it is in the browser cache yet), I made a few changes to my build file to scrape the <tt>&lt;head&gt;</tt> of my layout template (<tt>layout.php</tt>), which I made to look something like this:</p>
<p><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>DEV_MODE<span style="color: #66cc66;">&#41;</span>: <span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;link rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> href=<span style="color: #ff0000;">&quot;/layout/jquery.ui.selectmenu.css&quot;</span> /&gt;                                   &lt;!--MERGE ME--&gt;
  &lt;link rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> href=<span style="color: #ff0000;">&quot;/layout/fancybox/jquery.fancybox-1.3.4.css&quot;</span> /&gt;                         &lt;!--MERGE ME--&gt;
  &lt;link rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> href=<span style="color: #ff0000;">&quot;/layout/style.css&quot;</span> /&gt;                                                  &lt;!--MERGE ME--&gt;
&nbsp;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/jquery-1.4.4.min.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                                          &lt;!--MERGE ME--&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/jquery.base64.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                                             &lt;!--MERGE ME--&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/jquery-ui-1.8.10.custom.min.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                               &lt;!--MERGE ME--&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/jquery.ui.selectmenu.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                                      &lt;!--MERGE ME--&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/jquery.cookie.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                                             &lt;!--MERGE ME--&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/fancybox/jquery.fancybox-1.3.4.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                            &lt;!--MERGE ME--&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/jquery.ba-hashchange.min.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                                  &lt;!--MERGE ME--&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/jquery.writeCapture-1.0.5-min.js&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;                             &lt;!--MERGE ME--&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span>: <span style="color: #808080; font-style: italic;"># if (!DEV_MODE) ?&gt;</span>
  &lt;link href=<span style="color: #ff0000;">&quot;/layout/motherofall.css.gz?2&quot;</span> rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> /&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/3rdparty.js.gz?2&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></p>
<p>It&#8217;s very simple: All the files with a “<tt>&#038;lt!--MERGE ME--&gt;</tt>” comment on the same line got concatenated and gzipped into <tt>motherofall.css.gz</tt> and <tt>3rdparty.js.gz</tt> respectively, like so:</p>
<p><pre class="php">MERGE_JS_FILES := $<span style="color: #66cc66;">&#40;</span>shell grep <span style="color: #ff0000;">'&lt;script.*&lt;!--MERGE ME--&gt;'</span> layout/layout.php|sed -e <span style="color: #ff0000;">'s/^.*&lt;script src=&quot;<span style="color: #000099; font-weight: bold;">\/</span><span style="color: #000099; font-weight: bold;">\(</span>[^&quot;]*<span style="color: #000099; font-weight: bold;">\)</span>&quot;.*/<span style="color: #000099; font-weight: bold;">\1</span>/'</span><span style="color: #66cc66;">&#41;</span>
MERGE_CSS_FILES := $<span style="color: #66cc66;">&#40;</span>shell grep <span style="color: #ff0000;">'&lt;link.*&lt;!--MERGE ME--&gt;'</span> layout/layout.php|sed -e <span style="color: #ff0000;">'s/^.*&lt;link .*href=&quot;<span style="color: #000099; font-weight: bold;">\/</span><span style="color: #000099; font-weight: bold;">\(</span>[^&quot;]*<span style="color: #000099; font-weight: bold;">\)</span>&quot;.*/<span style="color: #000099; font-weight: bold;">\1</span>/'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
all: layout/3rdparty.js.gz layout/motherofall.css.gz
&nbsp;
layout/3rdparty.js.gz: layout/layout.php $<span style="color: #66cc66;">&#40;</span>MERGE_JS_FILES<span style="color: #66cc66;">&#41;</span>
        cat $<span style="color: #66cc66;">&#40;</span>MERGE_JS_FILES<span style="color: #66cc66;">&#41;</span> | gzip &gt; $@
&nbsp;
layout/motherofall.css.gz: layout/layout.php $<span style="color: #66cc66;">&#40;</span>MERGE_CSS_FILES<span style="color: #66cc66;">&#41;</span>
        cat $<span style="color: #66cc66;">&#40;</span>MERGE_CSS_FILES<span style="color: #66cc66;">&#41;</span> | gzip &gt; $@</pre></p>
<p>Of course, I simplified away the rest of my Makefile. You may notice that I could have used yui-compressor or something alike to minify the concatenated files before gzipping them, but yui-compressor chokes on some of the third-party stuff. I <em>am</em> using it for optimizing my own css/js (again, only in production).</p>
<h2>Safari ignores the <tt>Content-Type</tt> for anything ending in <tt>.gz</tt></h2>
<p>As far as the HTTP spec is concerned, “file” extensions mean absolutely nothing. They&#8217;re trivial drivel. Whether an URL ends in <tt>.gz</tt>, <tt>.css</tt>, <tt>.gif</tt> or <tt>.png</tt>, what it all comes down to is what the <tt>Content-Type</tt> header tells the browser about the response being sent.</p>
<p>You may have noticed me being lazy in the layout template above when I referenced the merged files:</p>
<p><pre class="php">&lt;link href=<span style="color: #ff0000;">&quot;/layout/motherofall.css.gz?2&quot;</span> rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> /&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/3rdparty.js.gz?2&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</pre></p>
<p>I chose to directly reference the gzipped version of the css/js, even though I had a <tt>.htaccess</tt> files in place (within <tt>/layout/</tt>) which was perfectly capable of using the right <tt>Content-Encoding</tt> for each <tt>Accept-Encoding</tt>.</p>
<h3><tt>$ cat /layout/.htaccess</tt></h3>
<p><pre class="ini">AddEncoding gzip .gz
&nbsp;
RewriteEngine On
&nbsp;
RewriteCond %<span style="">&#123;</span>HTTP:Accept-Encoding<span style="">&#125;</span> gzip
RewriteCond %<span style="">&#123;</span>REQUEST_FILENAME<span style="">&#125;</span>.gz -f
RewriteRule ^<span style="">&#40;</span>.*<span style="">&#41;</span>$ $<span style="">1</span>.gz <span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>QSA,L<span style="">&#93;</span></span>
&nbsp;
&lt;Files *.css.gz&gt;
ForceType text/css
&lt;/Files&gt;
&nbsp;
&lt;Files *.js.gz&gt;
ForceType application/javascript
&lt;/Files&gt;</pre></p>
<p>You may notice that the <tt>.htaccess</tt> file contains some configuration to make sure that the <tt>.gz</tt> files are not served as something like <tt>application/gzip-compressed</tt>.</p>
<p>Anyway, I went to see if there were any browsers left that do not yet <tt>Accept-Encoding: gzip</tt> and could find none. When, yesterday, I was faced with an unstyled version of my homepage, my first reaction was (after the one where I was like hitting reload 20 times, embarrassedly mumbling something about “those damn browser-caches!”): “O then, apparently, Safari must be some exception to the rule that browsers have all been supporting gzip encoding for like forever!”</p>
<p>No, it isn&#8217;t so. Apparently <em>Safari ignores the <tt>Content-Type</tt> header for any resource with an URL ending in <tt>.gz</tt>.</em> Yes, that&#8217;s right. Safari understand <tt>Content-Encoding: gzip</tt> just fine. Not problems. Just don&#8217;t call it <tt>.gz</tt>.</p>
<h2>The new <tt>cat ; gzip</tt></h2>
<p>So, let&#8217;s remove the <tt>.gz</tt> suffix from these files and be done with it. The <tt>.htaccess</tt> was already capable of instructing all necessary negotiations to be able to properly serve the gzipped version only when it&#8217;s accepted (which is always, but I digress).</p>
<p>A few adjustments to my <tt>Makefile</tt>:</p>
<p><pre class="php">MERGE_JS_FILES := $<span style="color: #66cc66;">&#40;</span>shell grep <span style="color: #ff0000;">'&lt;script.*&lt;!--MERGE ME--&gt;'</span> layout/layout.php|sed -e <span style="color: #ff0000;">'s/^.*&lt;script src=&quot;<span style="color: #000099; font-weight: bold;">\/</span><span style="color: #000099; font-weight: bold;">\(</span>[^&quot;]*<span style="color: #000099; font-weight: bold;">\)</span>&quot;.*/<span style="color: #000099; font-weight: bold;">\1</span>/'</span><span style="color: #66cc66;">&#41;</span>
MERGE_CSS_FILES := $<span style="color: #66cc66;">&#40;</span>shell grep <span style="color: #ff0000;">'&lt;link.*&lt;!--MERGE ME--&gt;'</span> layout/layout.php|sed -e <span style="color: #ff0000;">'s/^.*&lt;link .*href=&quot;<span style="color: #000099; font-weight: bold;">\/</span><span style="color: #000099; font-weight: bold;">\(</span>[^&quot;]*<span style="color: #000099; font-weight: bold;">\)</span>&quot;.*/<span style="color: #000099; font-weight: bold;">\1</span>/'</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
all: layout/3rdparty.js.gz layout/motherofall.css.gz layout/pfms.<a href="http://www.php.net/min"><span style="color: #000066;">min</span></a>.js.gz
&nbsp;
layout/3rdparty.js: layout/layout.php $<span style="color: #66cc66;">&#40;</span>MERGE_JS_FILES<span style="color: #66cc66;">&#41;</span>
	cat $<span style="color: #66cc66;">&#40;</span>MERGE_JS_FILES<span style="color: #66cc66;">&#41;</span> &gt; $@
&nbsp;
layout/motherofall.css: layout/layout.php $<span style="color: #66cc66;">&#40;</span>MERGE_CSS_FILES<span style="color: #66cc66;">&#41;</span>
	cat $<span style="color: #66cc66;">&#40;</span>MERGE_CSS_FILES<span style="color: #66cc66;">&#41;</span> &gt; $@
&nbsp;
%.gz: %
	gzip -c $^ &gt; $@</pre></p>
<p>And here&#8217;s the simple change to my <tt>layout.php</tt> template:</p>
<p><pre class="php">&lt;link href=<span style="color: #ff0000;">&quot;/layout/motherofall.css?2&quot;</span> rel=<span style="color: #ff0000;">&quot;stylesheet&quot;</span> type=<span style="color: #ff0000;">&quot;text/css&quot;</span> /&gt;
  &lt;script src=<span style="color: #ff0000;">&quot;/layout/3rdparty.js?2&quot;</span> type=<span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;/script&gt;</pre></p>
<p>That&#8217;s it. I welcome back all 14 Safari users looking for <a href="http://www.payformystay.com/">paid work abroad</a>! Be it that you&#8217;re looking for <a href="http://www.payformystay.com/">international work in Africa, in America, in Asia or in Europe</a>, please come visit and have a look at what we have on offer. <img src='http://blog.bigsmoke.us/wp-factory/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2012/01/16/safari-ignores-content-type-for-gz-suffix/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Allowing apache to set Nagios cmd file</title>
		<link>http://blog.bigsmoke.us/2010/12/28/allowing-apache-to-set-nagios-cmd-file</link>
		<comments>http://blog.bigsmoke.us/2010/12/28/allowing-apache-to-set-nagios-cmd-file#comments</comments>
		<pubDate>Tue, 28 Dec 2010 21:13:19 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[nagios]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1791</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>On debian, to prevent:</p>
<blockquote><p>Error: Could not stat() command file ‘/var/lib/nagios3/rw/nagios.cmd’!</p></blockquote>
<p>Do:</p>
<p><pre class="php">/etc/init.d/nagios3 stop
dpkg-statoverride --update --add nagios www-data <span style="color: #cc66cc;">2710</span> /<span style="color: #000000; font-weight: bold;">var</span>/lib/nagios3/rw
dpkg-statoverride --update --add nagios nagios <span style="color: #cc66cc;">751</span> /<span style="color: #000000; font-weight: bold;">var</span>/lib/nagios3
/etc/init.d/nagios3 start</pre></p>
<p><a href="http://lars-schenk.com/nagios-commands-via-web-interface-on-debian/446">source</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/12/28/allowing-apache-to-set-nagios-cmd-file/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apache rewrite rule to rewrite to sub dir</title>
		<link>http://blog.bigsmoke.us/2010/09/27/apache-rewrite-rule-to-rewrite-to-sub-dir</link>
		<comments>http://blog.bigsmoke.us/2010/09/27/apache-rewrite-rule-to-rewrite-to-sub-dir#comments</comments>
		<pubDate>Mon, 27 Sep 2010 14:38:03 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1585</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
One one particular site, I wanted to rewrite all requests to a sub dir. It took me over an hour, because of some obscure problem I haven&#8217;t been able to identify. 
</p>

<pre class="php"><span style="color: #808080; font-style: italic;"># The main site located in the /site dir. The .* after the ^ is weird, but without it, it wouldn't work.</span>
RewriteCond %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> !^.*/site/.*
RewriteRule ^<span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span>$ site$<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#91;</span>L,R=permanent<span style="color: #66cc66;">&#93;</span></pre>

<p>
My guess is it has to do with:
</p>

<pre class="php">AddHandler php-cgi-script .php
Action php-cgi-script /php5/php5-cgi</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/09/27/apache-rewrite-rule-to-rewrite-to-sub-dir/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rewrite rules to redirect to a temporary offline page</title>
		<link>http://blog.bigsmoke.us/2010/09/22/rewrite-rules-to-redirect-to-a-temporary-offline-page</link>
		<comments>http://blog.bigsmoke.us/2010/09/22/rewrite-rules-to-redirect-to-a-temporary-offline-page#comments</comments>
		<pubDate>Wed, 22 Sep 2010 12:29:56 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[rewriterule]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1574</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
Sometimes you want to take a site offline for a while. You can put this in .htaccess or the vhost config:
</p>

<pre class="php">ErrorDocument <span style="color: #cc66cc;">503</span> <span style="color: #ff0000;">&quot;Site is temporarily offline.&quot;</span>
        RewriteEngine On
        RewriteRule .* - <span style="color: #66cc66;">&#91;</span>R=<span style="color: #cc66cc;">503</span>,L<span style="color: #66cc66;">&#93;</span></pre>

<p>
When using .htaccess, be sure to have AllowOverride All.
</p>

<p>
Or when using HTML files and images:
</p>

<pre class="php">&lt;VirtualHost *&gt;
  ServerAdmin webmaster@ytec.nl
  ServerName www.example.nl
&nbsp;
  DocumentRoot /<span style="color: #000000; font-weight: bold;">var</span>/www/down/
&nbsp;
  ErrorDocument <span style="color: #cc66cc;">503</span> /maintenance.html
&nbsp;
  RewriteCond %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> =/maintenance.html <span style="color: #66cc66;">&#91;</span>OR<span style="color: #66cc66;">&#93;</span>
  RewriteCond %<span style="color: #66cc66;">&#123;</span>REQUEST_URI<span style="color: #66cc66;">&#125;</span> =/logo.jpg
  RewriteRule <span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span> $<span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#91;</span>L<span style="color: #66cc66;">&#93;</span>
&nbsp;
  RewriteEngine On
  RewriteRule .* - <span style="color: #66cc66;">&#91;</span>R=<span style="color: #cc66cc;">503</span>,L<span style="color: #66cc66;">&#93;</span>
&lt;/VirtualHost&gt;</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/09/22/rewrite-rules-to-redirect-to-a-temporary-offline-page/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preventing IOerror on stdout with modWSGI</title>
		<link>http://blog.bigsmoke.us/2010/09/10/preventing-ioerror-on-stdout-with-modwsgi</link>
		<comments>http://blog.bigsmoke.us/2010/09/10/preventing-ioerror-on-stdout-with-modwsgi#comments</comments>
		<pubDate>Fri, 10 Sep 2010 15:57:09 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[django]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wsgi]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1564</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
By default, you can&#8217;t use prints in a django app, because mod_wsgi restricts that. You can change that by putting this in your configuration:
</p>

<pre class="php">WSGIRestrictStdout Off</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/09/10/preventing-ioerror-on-stdout-with-modwsgi/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing an apache virtual host to ssl</title>
		<link>http://blog.bigsmoke.us/2010/09/07/changing-an-apache-virtual-host-to-ssl</link>
		<comments>http://blog.bigsmoke.us/2010/09/07/changing-an-apache-virtual-host-to-ssl#comments</comments>
		<pubDate>Tue, 07 Sep 2010 13:07:05 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1559</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
To change a virtual host in apache to ssl:
</p>

<pre class="php"><span style="color: #808080; font-style: italic;">#Redirect all normal traffic to the https site.</span>
&lt;VirtualHost *:<span style="color: #cc66cc;">80</span>&gt;
  RewriteEngine on
  RewriteRule ^/<span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span> https:<span style="color: #808080; font-style: italic;">//%{HTTP_HOST}/$1 [L,R]</span>
&lt;/VirtualHost&gt;
&nbsp;
<span style="color: #808080; font-style: italic;"># This virtual host was *:80 first</span>
&lt;VirtualHost *:<span style="color: #cc66cc;">443</span>&gt;
   DocumentRoot /bla
&nbsp;
   <span style="color: #808080; font-style: italic;"># These lines were added to make it SSL</span>
   SSLEngine on
   SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
   SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.<a href="http://www.php.net/key"><span style="color: #000066;">key</span></a>
   <span style="color: #808080; font-style: italic;"># if you have an official certificate, also add some of these:</span>
   SSLCertificateChainFile /etc/ssl/certs/bla
&nbsp;
   &lt;Directory /bla&gt;
      Order allow,deny
      Allow from all
      AllowOverride None
      Options -MultiViews FollowSymlinks Indexes
   &lt;/Directory&gt;
&nbsp;
&lt;/VirtualHost&gt;</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/09/07/changing-an-apache-virtual-host-to-ssl/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect multiple domains to one</title>
		<link>http://blog.bigsmoke.us/2010/09/07/redirect-multiple-domains-to-one</link>
		<comments>http://blog.bigsmoke.us/2010/09/07/redirect-multiple-domains-to-one#comments</comments>
		<pubDate>Tue, 07 Sep 2010 09:38:54 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[rewriterule]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1555</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
When a site is available under multiple domains, it is usually bad idea to not have them all redirect to one domain. In apache, do this:
</p>

<pre class="php">RewriteEngine On
RewriteCond %<span style="color: #66cc66;">&#123;</span>HTTP_HOST<span style="color: #66cc66;">&#125;</span>   !=www.domain.com
RewriteRule ^<span style="color: #66cc66;">&#40;</span>.*<span style="color: #66cc66;">&#41;</span>$         http:<span style="color: #808080; font-style: italic;">//www.domain.com$1 [L,R=permanent] </span></pre>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/09/07/redirect-multiple-domains-to-one/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Disabling debug for mod wsgi</title>
		<link>http://blog.bigsmoke.us/2010/08/06/disabling-debug-for-mod-wsgi</link>
		<comments>http://blog.bigsmoke.us/2010/08/06/disabling-debug-for-mod-wsgi#comments</comments>
		<pubDate>Fri, 06 Aug 2010 15:41:50 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[mod_wsgi]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[wsgi]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1531</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
For the record, when deploying mod wsgi apps, remember to enable optimizations in mod_wsgi.conf. Otherwise debug will be true.
</p>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/08/06/disabling-debug-for-mod-wsgi/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating a self-signed SSL certificate</title>
		<link>http://blog.bigsmoke.us/2010/05/16/generating-a-self-signed-ssl-certificate</link>
		<comments>http://blog.bigsmoke.us/2010/05/16/generating-a-self-signed-ssl-certificate#comments</comments>
		<pubDate>Sun, 16 May 2010 21:42:51 +0000</pubDate>
		<dc:creator>halfgaar</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=1418</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>
<a href="http://www.akadia.com/services/ssh_test_certificate.html">This article</a> explains nicely how to make a self-signed SSL certificate, for Apache for instance:
</p>

<pre class="bash">openssl genrsa -des3 -out server.key <span style="color: #cc66cc;">2048</span>
openssl req -new -key server.key -out server.csr
cp server.key server.key.org
openssl rsa -<span style="color: #b1b100;">in</span> server.key.org -out server.key <span style="color: #808080; font-style: italic;"># remove passphrase from key</span>
openssl x509 -req -days <span style="color: #cc66cc;">3650</span> -<span style="color: #b1b100;">in</span> server.csr -signkey server.key -out server.crt</pre>

<p>
However, later I found this to generate a CSR and key:
</p>

<pre class="php">openssl req -nodes -newkey rsa:<span style="color: #cc66cc;">2048</span> -keyout bla.<a href="http://www.php.net/key"><span style="color: #000066;">key</span></a> -out bla.csr</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/05/16/generating-a-self-signed-ssl-certificate/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MediaWiki thumb.php and rewrite rules</title>
		<link>http://blog.bigsmoke.us/2010/03/07/mediawiki-thumb.php-rewrite-rules</link>
		<comments>http://blog.bigsmoke.us/2010/03/07/mediawiki-thumb.php-rewrite-rules#comments</comments>
		<pubDate>Sun, 07 Mar 2010 18:40:26 +0000</pubDate>
		<dc:creator>Rowan Rodrik</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[MediaWiki]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[thumbnail]]></category>

		<guid isPermaLink="false">http://blog.bigsmoke.us/?p=516</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>May, last year, I created an empty draft for this post, because, around that time, I had gone through quite some effort before I got thumbnails for foreign file repos working just right. Now, I&#8217;m taking a dive into my MediaWiki working dirs in preparation of the creation of a separate development environment, so it&#8217;s a good moment to rehash the past experience (almost as good as when I&#8217;d have done it right away).</p>

<p>This is how I configured the <a href="http://www.mediawiki.org/wiki/Manual:$wgForeignFileRepos">foreign file repo</a> to be able to use images uploaded to the English wiki from the Dutch wiki:</p>

<pre class="php"><span style="color: #0000ff;">$wgHashedUploadDirectory</span> = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
<span style="color: #0000ff;">$wgForeignFileRepos</span><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> = <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span>
    <span style="color: #ff0000;">'class'</span> =&gt; <span style="color: #ff0000;">'ForeignDBRepo'</span>,
    <span style="color: #ff0000;">'name'</span> =&gt; <span style="color: #ff0000;">'en'</span>,
    <span style="color: #ff0000;">'url'</span> =&gt; <span style="color: #ff0000;">&quot;http://wiki.hardwood-investments.net/media&quot;</span>,
    <span style="color: #ff0000;">'hashLevels'</span> =&gt; <span style="color: #cc66cc;">0</span>,
    <span style="color: #808080; font-style: italic;">//'thumbScriptUrl' =&gt; &quot;http://wiki.hardwood-investments.net/thumb.php&quot;,</span>
    <span style="color: #ff0000;">'transformVia404'</span> =&gt; <span style="color: #000000; font-weight: bold;">true</span>,<span style="color: #808080; font-style: italic;">//!$wgGenerateThumbnailOnParse,</span>
    <span style="color: #ff0000;">'dbType'</span> =&gt; <span style="color: #0000ff;">$wgDBtype</span>,
    <span style="color: #ff0000;">'dbServer'</span> =&gt; <span style="color: #0000ff;">$wgDBserver</span>,
    <span style="color: #ff0000;">'dbUser'</span> =&gt; <span style="color: #0000ff;">$wgDBuser</span>,
    <span style="color: #ff0000;">'dbPassword'</span> =&gt; <span style="color: #0000ff;">$wgDBpassword</span>,
    <span style="color: #ff0000;">'dbName'</span> =&gt; <span style="color: #ff0000;">'hardwood'</span>,
    <span style="color: #ff0000;">'tablePrefix'</span> =&gt; <span style="color: #ff0000;">'mw_'</span>,
    <span style="color: #ff0000;">'hasSharedCache'</span> =&gt; <span style="color: #000000; font-weight: bold;">false</span>,
    <span style="color: #ff0000;">'descBaseUrl'</span> =&gt; <span style="color: #ff0000;">'http://wiki.hardwood-investments.net/Image:'</span>,
    <span style="color: #ff0000;">'fetchDescription'</span> =&gt; <span style="color: #000000; font-weight: bold;">false</span>
<span style="color: #66cc66;">&#41;</span>;</pre>

<p>To make thumbnails be generated by <a href="http://www.mediawiki.org/wiki/Manual:Thumb.php"><tt>thumb.php</tt></a> on request I added the following to my <tt>.htaccess</tt> at the other end (and visa versa, because the Dutch wiki actually contains most of the images):</p>

<pre class="php">RewriteCond %<span style="color: #66cc66;">&#123;</span>REQUEST_FILENAME<span style="color: #66cc66;">&#125;</span> !-f
RewriteCond %<span style="color: #66cc66;">&#123;</span>REQUEST_FILENAME<span style="color: #66cc66;">&#125;</span> !-d
RewriteRule ^media/thumb/<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span>^/<span style="color: #66cc66;">&#93;</span>+<span style="color: #66cc66;">&#41;</span>/<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #cc66cc;">-9</span><span style="color: #66cc66;">&#93;</span>+<span style="color: #66cc66;">&#41;</span>px-.*$ /thumb.php?f=$<span style="color: #cc66cc;">1</span>&amp;width=$<span style="color: #cc66cc;">2</span> <span style="color: #66cc66;">&#91;</span>L,QSA<span style="color: #66cc66;">&#93;</span></pre>]]></content:encoded>
			<wfw:commentRss>http://blog.bigsmoke.us/2010/03/07/mediawiki-thumb.php-rewrite-rules/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

