<?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>MRo Blog &#187; apache</title>
	<atom:link href="http://blog.mro.name/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mro.name</link>
	<description>Marcus Rohrmoser mobile Software</description>
	<lastBuildDate>Wed, 23 Jun 2010 11:32:27 +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>Simple HTTP Access Authorisation</title>
		<link>http://blog.mro.name/2010/06/simple-http-access-authorisation/</link>
		<comments>http://blog.mro.name/2010/06/simple-http-access-authorisation/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 09:56:46 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[authorisation]]></category>
		<category><![CDATA[Basic Authentication]]></category>
		<category><![CDATA[Cram]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[HTTPS]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[rest]]></category>
		<category><![CDATA[restful]]></category>
		<category><![CDATA[RewriteCond]]></category>
		<category><![CDATA[RewriteRule]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1872</guid>
		<description><![CDATA[sometimes you may want to lock down RESTful APIs or plain HTTP GET resources for authorised access by your own client software only, without requiring authentication. You don&#8217;t know who (not authenticated), but you know she may access (is authorised). If the server has a valid SSL certificate based on a root certificate pre-installed on the [...]]]></description>
			<content:encoded><![CDATA[<p>sometimes you may want to lock down <a href="http://en.wikipedia.org/wiki/Representational_State_Transfer">RESTful APIs</a> or plain HTTP GET resources for <a href="http://en.wikipedia.org/wiki/Authorization">authorised access</a> by your own client software only, without requiring <a href="http://en.wikipedia.org/wiki/Authentication">authentication</a>. You don&#8217;t know who (not authenticated), but you know she may access (is authorised).</p>
<p>If the server has a valid <a href="http://httpd.apache.org/docs/2.0/ssl/ssl_faq.html">SSL certificate</a> based on a root certificate pre-installed on the iPhone among the simplest ways to do it are:</p>
<ul>
<li><a href="http://en.wikipedia.org/wiki/Basic_access_authentication">HTTP Basic Authentication</a> with static username + password. This requires just a <a href="http://httpd.apache.org/docs/2.0/mod/core.html#authtype"><code>.htaccess</code> configuration setting</a> and you&#8217;re done.</li>
<li>send a custom <a href="http://www.w3.org/Protocols/HTTP/HTRQ_Headers.html">HTTP Request Header</a> with a secret token, also just a <code><a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">.htaccess</a></code><a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html"> rewrite</a> setting required:

<div class="wp_syntax"><div class="code"><pre class="htaccess" style="font-family:monospace;">RewriteEngine On
RewriteCond %{HTTP:My-Secret-Token} !=WRdsWXwwTZjEIRrgD5tODVf0U
RewriteRule ^.*$ - [forbidden,last]
# Test: $  curl --header &quot;My-Secret-Token:WRdsWXwwTZjEIRrgD5tODVf0U&quot; http://myserver.example.com/demo/</pre></div></div>

</li>
</ul>
<p>Decompiling an App may raise the bar high enough though hard-coded secrets surely aren&#8217;t bulletproof Secret Service grade quality. If you don&#8217;t want the password or secret token as literal string inside the App, synthesize it at runtime.</p>
<p>If your transport channel isn&#8217;t confidential (e.g. plain HTTP, not HTTPS) you might think about <a href="http://en.wikipedia.org/wiki/Digest_access_authentication">Digest Authentication</a> or a custom implemented <a href="http://en.wikipedia.org/wiki/CRAM-MD5">CRAMish</a> mechanism which I will not go into in this post.</p>
<p>P.S.: <a href="http://www.evolt.org/ultimate_htaccess_examples">Here are some really nice <code>.htaccess</code> examples</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2010/06/simple-http-access-authorisation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic gzip compression for Apache2 Webservers</title>
		<link>http://blog.mro.name/2010/06/automatic-gzip-compression-for-apache2-webservers/</link>
		<comments>http://blog.mro.name/2010/06/automatic-gzip-compression-for-apache2-webservers/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 11:55:25 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Articles in english]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[gzip]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mod_deflate]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1864</guid>
		<description><![CDATA[after failing and failing again in the last months, I finally got it with the help of http://www.debian-administration.org/articles/137 The .htaccess configuration AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript requires Apache&#8217;s mod_deflate enabled via $ a2enmod deflate Module deflate installed; run /etc/init.d/apache2 force-reload to enable. Check the result with http://www.gidnetwork.com/tools/gzip-test.php Caution: There seems to be an [...]]]></description>
			<content:encoded><![CDATA[<p>after failing and failing again in the last months, I finally got it with the help of <a href="http://www.debian-administration.org/articles/137">http://www.debian-administration.org/articles/137</a></p>
<p>The <code>.htaccess</code> configuration</p>

<div class="wp_syntax"><div class="code"><pre class="htaccess" style="font-family:monospace;">AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript</pre></div></div>

<p>requires Apache&#8217;s <code>mod_deflate</code> enabled via</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ a2enmod deflate
Module deflate installed; run <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>apache2 force-reload to enable.</pre></div></div>

<p>Check the result with <a href="http://www.gidnetwork.com/tools/gzip-test.php">http://www.gidnetwork.com/tools/gzip-test.php</a></p>
<p><strong>Caution:</strong> There seems to be an <a href="http://phpperformance.de/mod_gzip-mod_deflate-und-sonstige-komprimierungsverfahren-fuer-web-inhalte/#comment-17970">If-Modified-Since/Last-Modified HTTP 304 bug in mod_deflate</a>, so better don&#8217;t use it for large, rarely changing files.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2010/06/automatic-gzip-compression-for-apache2-webservers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>hübsche Dropbox Links</title>
		<link>http://blog.mro.name/2010/01/hubsche-dropbox-links/</link>
		<comments>http://blog.mro.name/2010/01/hubsche-dropbox-links/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 13:09:31 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Artikel auf deutsch]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[Dropbox]]></category>
		<category><![CDATA[Email]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[Netiquette]]></category>
		<category><![CDATA[Redirect]]></category>
		<category><![CDATA[RewriteEngine]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1633</guid>
		<description><![CDATA[Weil große Email Anhänge stinken, bietet sich z.B. die Dropbox als Dateiaustauschplatform an. Einfach die Datei in den (lokalen) Dropbox/Public Ordner verfrachten, syncen lassen und per &#8220;Rechte Maustaste -&#62; Copy Public Link&#8221; in die Mail kopieren. Redirect Nun sind solche Links nicht besonders hübsch (Branding!, Branding!, CI! ruft die Marketingabteilung) und  spätestens wenn man&#8217;s abtippen [...]]]></description>
			<content:encoded><![CDATA[<p>Weil <a href="http://friendfeed.com/akawee/10ab93b0/e-mail-missbrauch-teil-2-der-anhang-ist-oft-die">große Email Anhänge stinken</a>, bietet sich z.B. die <a href="http://friendfeed.com/webjuwelen/9ed5b1a9/skrupellose-werbung-fur-die-dropbox-dieser">Dropbox</a> als Dateiaustauschplatform an.</p>
<p>Einfach die Datei in den (lokalen) Dropbox/Public Ordner verfrachten, syncen lassen und per &#8220;Rechte Maustaste -&gt; Copy Public Link&#8221; in die Mail kopieren.</p>
<h3>Redirect</h3>
<p>Nun sind solche Links nicht besonders hübsch (Branding!, Branding!, CI! ruft die Marketingabteilung) und  spätestens wenn man&#8217;s abtippen muß oder per Telephon weitersagt wird&#8217;s gruslig.</p>
<p>Hat man aber eine eigene Website, lassen sich die <a href="http://www.cimitan.com/blog/2008/09/17/htaccess-to-redirect-on-dropboxs-public-folder/#">Dropbox Links aufhübschen</a> und eine Weiterleitung einrichten, dann wird aus</p>
<pre>http://dl.dropbox.com/u/1234567/BigDocument.pdf</pre>
<p>z.B.</p>
<pre>http://dropbox.mydomain.com/BigDocument.pdf</pre>
<p>und schon sind die Brandingfreunde happy.</p>
<h3>index.html</h3>
<p>Geht es nicht um eine einzelne Datei sondern um mehrere, will man evtl. eine Übersicht in einer index.html haben. So eine Übersicht legt z.B. mein <a href="http://www.ruby-lang.org/de/">ruby</a> Script <a href="http://gist.github.com/271223">htmlizedb</a> an. Das Script will im <a href="http://de.wikipedia.org/wiki/Bourne-again_shell">Terminal</a> in dem Verzeichnis gestartet werden, für das die Übersicht her soll.</p>
<h3>Redirect + index.html</h3>
<p>Bei Webservern ist allgemein üblich, daß man den Dateinamen index.html im Link weglassen kann. Der Webserver nimmt dann an man meint selbige. Die Dropbox verhält sich aber in dieser Hinsicht nicht wie ein normaler Webserver, sondern will immer den kompletten Dateinamen.</p>
<p>Hat man aber bereits den Redirect Trick in Benutzung, läßt sich die Redirect Steuerdatei (<code>.htaccess</code>) aufbohren, daß der Redirect die index.html Angabe ergänzt:</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">RewriteEngine</span> <span style="color: #0000ff;">on</span>
<span style="color: #adadad; font-style: italic;"># dropbox abbreviation:</span>
<span style="color: #adadad; font-style: italic;"># http://www.cimitan.com/blog/2008/09/17/htaccess-to-redirect-on-dropboxs-public-folder/#</span>
<span style="color: #adadad; font-style: italic;"># last path component has no dot -&amp;gt; redirect to index.html</span>
<span style="color: #00007f;">RewriteRule</span> ^(.+/)?([^./]+)/?$	http://dl.dropbox.com/u/<span style="color: #ff0000;">1234567</span>/$<span style="color: #ff0000;">1</span>$<span style="color: #ff0000;">2</span>/index.html	[last,qsappend]
<span style="color: #adadad; font-style: italic;"># everything else: redirect as is</span>
<span style="color: #00007f;">RewriteRule</span> ^(.+)$	http://dl.dropbox.com/u/<span style="color: #ff0000;">1234567</span>/$<span style="color: #ff0000;">1</span>	[last,qsappend]</pre></div></div>

<p>violá, nun wird von</p>
<pre>http://dropbox.mydomain.com/FolderWithBigFiles</pre>
<p>automatisch auf den Dropbox Link</p>
<pre>http://dl.dropbox.com/u/1234567/FolderWithBigFiles/index.html</pre>
<p>weitergeleitet.</p>
<p>Toll, nicht?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2010/01/hubsche-dropbox-links/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ruby: parse Apache Serverlogs</title>
		<link>http://blog.mro.name/2009/07/ruby-parse-apache-serverlogs/</link>
		<comments>http://blog.mro.name/2009/07/ruby-parse-apache-serverlogs/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 21:59:43 +0000</pubDate>
		<dc:creator>mro</dc:creator>
				<category><![CDATA[Articles in english]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[logfile]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[serverlogs]]></category>

		<guid isPermaLink="false">http://blog.mro.name/?p=1108</guid>
		<description><![CDATA[Yields a hashmap for every line: require 'date' &#160; class Apache def self.each_request&#40;src=$stdin&#41; ip_pat=/&#40;?:&#91;0-9&#93;+\.&#41;&#123;3&#125;&#91;0-9&#93;+/ date_pat=/\&#91;&#91;^\&#93;&#93;+\&#93;/ req_pat=/&#34;([A-Z]+)\s([^\s]+)\s([^\s]+)&#34;/ ref_pat=/&#34;([^&#34;&#93;+&#41;&#34;/ date_fmt = '[%d/%b/%Y:%H:%M:%S %Z]' apache_pat = Regexp.new( &#34;&#40;#{ip_pat})\s([^\s]+)\s([^\s]+)\s&#34; &#60; &#60; &#34;(#{date_pat})\s#{req_pat}\s([0-9]+)\s(-&#124;[0-9]+)\s#{ref_pat}\s#{ref_pat}&#34;&#41; src.each_line do &#124;l&#124; m = apache_pat.match l if m r = &#123; :ip =&#62; m&#91;1&#93;, :uid =&#62; m&#91;2&#93;, :auth =&#62; m&#91;3&#93;, :date =&#62; DateTime.strptime&#40;m&#91;4&#93;,date_fmt&#41;, :method =&#62; m&#91;5&#93;, [...]]]></description>
			<content:encoded><![CDATA[<p>Yields a hashmap for every line:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'date'</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">class</span> Apache
  <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">each_request</span><span style="color:#006600; font-weight:bold;">&#40;</span>src=$stdin<span style="color:#006600; font-weight:bold;">&#41;</span>
    ip_pat=<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>?:<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span>\.<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">0</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+/</span>
    date_pat=<span style="color:#006600; font-weight:bold;">/</span>\<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#91;</span>^\<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span>\<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">/</span>
    req_pat=<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;([A-Z]+)<span style="color:#000099;">\s</span>([^<span style="color:#000099;">\s</span>]+)<span style="color:#000099;">\s</span>([^<span style="color:#000099;">\s</span>]+)&quot;</span><span style="color:#006600; font-weight:bold;">/</span>
    ref_pat=<span style="color:#006600; font-weight:bold;">/</span><span style="color:#996600;">&quot;([^&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">+</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#996600;">&quot;/
    date_fmt = '[%d/%b/%Y:%H:%M:%S %Z]'
    apache_pat = Regexp.new( &quot;</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#008000; font-style:italic;">#{ip_pat})\s([^\s]+)\s([^\s]+)\s&quot; &lt; &lt;</span>
      <span style="color:#996600;">&quot;(#{date_pat})<span style="color:#000099;">\s</span>#{req_pat}<span style="color:#000099;">\s</span>([0-9]+)<span style="color:#000099;">\s</span>(-|[0-9]+)<span style="color:#000099;">\s</span>#{ref_pat}<span style="color:#000099;">\s</span>#{ref_pat}&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    src.<span style="color:#9900CC;">each_line</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>l<span style="color:#006600; font-weight:bold;">|</span>
      m = apache_pat.<span style="color:#9900CC;">match</span> l
      <span style="color:#9966CC; font-weight:bold;">if</span> m
        r = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:ip</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:uid</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:auth</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:date</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC00FF; font-weight:bold;">DateTime</span>.<span style="color:#9900CC;">strptime</span><span style="color:#006600; font-weight:bold;">&#40;</span>m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">4</span><span style="color:#006600; font-weight:bold;">&#93;</span>,date_fmt<span style="color:#006600; font-weight:bold;">&#41;</span>,
          <span style="color:#ff3333; font-weight:bold;">:method</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">6</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:http</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">7</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:status</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">8</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:bytes</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">9</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:referrer</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#93;</span>,
          <span style="color:#ff3333; font-weight:bold;">:agent</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> m<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006666;">11</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
        <span style="color:#9966CC; font-weight:bold;">yield</span> r
       <span style="color:#9966CC; font-weight:bold;">else</span>
        <span style="color:#ff6633; font-weight:bold;">$stderr</span>.<span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Unparseable line: '#{l}'&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>maybe there are faster ways, but it&#8217;s quite convenient this way.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mro.name/2009/07/ruby-parse-apache-serverlogs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
