<?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>Too Far Afield &#187; apache</title>
	<atom:link href="http://blog.nachtarbeiter.net/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.nachtarbeiter.net</link>
	<description></description>
	<lastBuildDate>Mon, 09 Jan 2012 05:41:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Monitoring PowerDNS via the internal web server</title>
		<link>http://blog.nachtarbeiter.net/2010/02/16/monitoring-powerdns-via-the-internal-web-server/</link>
		<comments>http://blog.nachtarbeiter.net/2010/02/16/monitoring-powerdns-via-the-internal-web-server/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 07:02:12 +0000</pubDate>
		<dc:creator>Patrick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[pdns]]></category>
		<category><![CDATA[powerdns]]></category>

		<guid isPermaLink="false">http://stage.nachtarbeiter.net/?p=585</guid>
		<description><![CDATA[If you want to stay informed about the current status of your PowerDNS server, there is no need to scan the logs or use third party tools like logcheckd. Actually, you might want to do this anyway, but PowerDNS provides an internal web server, which summarizes all the status information (including log messages) in a [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to stay informed about the current status of your <cite>PowerDNS</cite> server, there is no need to scan the logs or use third party tools like <code>logcheckd</code>. Actually, you might want to do this anyway, but <cite>PowerDNS</cite> provides an internal web server, which summarizes all the status information (including log messages) in a very nice and compact way for you to view.</p>
<p>By default, the web server will listen on port <code>8081</code> on <code>localhost</code>. That means, that you can&#8217;t view the status information from the outside network. To view the page, you could use a command line browser like <code>lynx</code>. You could change the interface of the web server to a public IP address, but this is <strong>very insecure</strong> and not recommended. The <cite>PowerDNS</cite> web server provides some sensitive information about your DNS server and you should not expose this information to the public. Also, the <cite>PowerDNS</cite> web server is probably not as thoroughly tested and hardened as <abbr title="for example">e.g.</abbr> <cite>Apache</cite> or <cite>nginx</cite>.  Another problem is, that you can only specify a single password and that you are limited to basic authentication, which is not very secure.</p>
<p>There is a secure way to retrieve the information provided by <cite>PowerDNS</cite> from outside your DNS server host. You could use <cite>Apache</cite>, <cite>nginx</cite> or any other web server you like as a proxy server. That way you can use more advanced authentication methods built into that web server to secure your status page. I will now show you how to do this using Apache 2 on Debian. We&#8217;ll need <code>mod_proxy</code>, <code>mod_proxy_http</code> and <code>mod_headers</code> enabled on the Apache 2 server. If you do not want to run an instance of Apache 2 on your DNS server, you could use an SSL tunnel or a secure back channel link to a remote Apache server to retrieve the status page. But this is beyond the scope of this post.</p>
<p>First, enable the internal <cite>PowerDNS</cite> web server by editing the configuration file.</p>
<ol class="code">
<li><code>webserver=yes</code></li>
<li><code>webserver-address=127.0.0.1</code></li>
<li><code>webserver-port=8081</code></li>
<li><code>webserver-password=PowerDNS</code></li>
</ol>
<p>This tells <cite>PowerDNS</cite> to run the internal web server on port <code>8081</code> of the <code>localhost</code> interface. The user name will be <code>admin</code> and the password will be <code>PowerDNS</code>. Of course you should change the password to something more secure, it&#8217;s just an example. After a restart of <cite>PowerDNS</cite> you can connect to your server from your DNS server host. The password is optional, but it&#8217;s safer that way, especially in an environment where you&#8217;ve got other users on your DNS server box.</p>
<p>Now install and enable the required modules of Apache 2 by executing the following commands.</p>
<ol class="code">
<li><code>apt-get install libapache2-mod-proxy-html</code></li>
<li><code>a2enmod proxy</code></li>
<li><code>a2enmod proxy_http</code></li>
<li><code>a2enmod headers</code></li>
</ol>
<p>The last module is only needed, if you set a password for your internal web server as recommended above. I assume that you&#8217;ve got some kind of virtual host configuration for your Apache server. You&#8217;ll want to add a new virtual host for the DNS status information. If you use a subdirectory, navigation might be a bit odd. Let&#8217;s add a new site to the available sites.</p>
<ol class="code">
<li><code>vi /etc/apache2/sites-available/status.dns.example.net</code></li>
<li><code>&lt;VirtualHost 192.168.0.1:80&gt;</code></li>
<li><code>        ServerName status.dns.example.net</code></li>
<li><code>        DocumentRoot /var/www/</code></li>
<li><code></code></li>
<li><code>        ProxyRequests Off</code></li>
<li><code>        &lt;proxy *&gt;</code></li>
<li><code>               Order deny,allow</code></li>
<li><code>               Allow from all</code></li>
<li><code>                ForceType 'text/html; charset=UTF-8'</code></li>
<li><code>        &lt;/proxy&gt;</code></li>
<li><code>        ProxyPass / http://localhost:8081</code></li>
<li><code>        ProxyPassReverse / http://localhost:8081</code></li>
<li><code></code></li>
<li><code>&lt;/VirtualHost&gt;</code></li>
</ol>
<p>Alright, so what are we doing here? Basically, we&#8217;re adding a new virtual host <code>status.dns.example.net</code> on our main interface of <code>dns.example.net</code>. We&#8217;re using a reverse proxy to to send all requests coming from the outside to our internal <cite>PowerDNS</cite> web server on port <code>8081</code>. Also, we&#8217;re forcing a <code>text/html</code> content type in the proxy request filter, because otherwise we would just get <code>text/plain</code> and we would simply see the source code, which is probably not what you want. Let&#8217;s enable the site for a test:</p>
<ol class="code">
<li><code>a2ensite status.dns.example.net</code></li>
<li><code>/etc/init.d/apache2 reload</code></li>
</ol>
<p>If you point your web browser to <code>status.dns.example.net</code> you should now see the internal status page of <cite>PowerDNS</cite>. If you set a password above, you will see a password dialogue. This is the password dialogue sent by the <cite>PowerDNS</cite> web server. The user name is <code>admin</code> and the password is your password. Try it out now, because we&#8217;ll get rid of this in a minute.</p>
<p>For security reasons, you probably want to use Apache 2 for authentication. E.g. you might want use a SSL connection and authenticate your co-workers using the internal LDAP server of your company intranet. You might even stay with the insecure basic authentication method, but use other user names. This is entirely up to you and beyond the scope of this post. Consult the Apache 2 documentation on how to do this. What you probably don&#8217;t want to do, however, is to authenticate twice (first your secure authentication method and then <cite>PowerDNS</cite> basic authentication. Luckily, we can configure the Apache 2 proxy to do the authentication for us. This is a bit tricky, though.<br />
To authenticate at the <cite>PowerDNS</cite> server, Apache 2 needs to send an additional <code>Authorization</code> header line to the <cite>PowerDNS</cite> server with every request it handles. We use the <code>RequestHeader</code> directive to override any existing <code>Authorization</code> header with our own authentication data. Add the following lines just before the end of the virtual host container.</p>
<ol class="code">
<li><code>        &lt;Location /&gt;</code></li>
<li><code>                RequestHeader Set Authorization "Basic YWRtaW46UG93ZXJETlM="</code></li>
<li><code>        &lt;/Location&gt;</code></li>
</ol>
<p>The above example works only for our example password, which is <code>PowerDNS</code>. Try it for a test. This is, because part of the header value is encrypted using the <code>base64</code> algorithm. You need to change the encrypted part <code>YWRtaW46UG93ZXJETlM=</code>. In plain text the encrypted string would read <code>admin:PowerDNS</code>, where <code>admin</code> is the user name and <code>PowerDNS</code> is the password. To use your own password, you need to encrypt the string <code>admin:yourownpassword</code> using the <code>base64</code> algorithm and replace our example string. Be sure to keep the <code>Basic</code> and the space. It is crucial for success, that you&#8217;ve got the right encrypted string. There are a number of <a href="http://www.motobit.com/util/base64-decoder-encoder.asp">online tools</a>, to encode and decode these strings. To ensure, that you&#8217;ve got the correct encryption method, encode the example string and compare it to the string above for a reference. If you&#8217;ve got the wrong string, it will not work.</p>
<p>Restart the Apache 2 server. To clear your password cache, restart your browser. Now surf to the site again. You will see, that the password dialogue is gone. Now, don&#8217;t forget to secure the page again using Apache 2. Under any circumstances, do <em>not</em> use <code>Directory</code> containers in the configuration. These will not apply to the proxy, because the proxy is not a physical directory on your server. Use <code>Location</code> containers like we did above for setting the <code>RequestHeader</code> directive. Also, you could still use insecure basic authentication to secure the page, if you wanted. It would work regardless of the <code>RequestHeader</code> magic.</p>
<h3>A light-weight alternative</h3>
<p>For those of you, who think that <cite>Apache</cite> is too heavy, here is an example for the <cite>nginx</cite> web server:</p>
<ol class="code">
<li><code>vi /etc/nginx/sites-available/status.dns.example.net</code></li>
<li><code>server {</code></li>
<li><code>   listen 192.168.0.1:80;</code></li>
<li><code>   server_name status.dns.example.net;</code></li>
<li><code>   root /var/www/nginx-default;</code></li>
<li><code>   location / {</code></li>
<li><code>      index index.html</code></li>
<li><code>      proxy_pass http://localhost:8081;</code></li>
<li><code>      proxy_redirect off;</code></li>
<li><code>      proxy_set_header Authorization "Basic YWRtaW46UG93ZXJETlM=";</code></li>
<li><code>   }</code></li>
<li><code>}</code></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://blog.nachtarbeiter.net/2010/02/16/monitoring-powerdns-via-the-internal-web-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting rid of Apache pass-phrase dialogs</title>
		<link>http://blog.nachtarbeiter.net/2009/08/20/getting-rid-of-apache-pass-phrase-dialogs/</link>
		<comments>http://blog.nachtarbeiter.net/2009/08/20/getting-rid-of-apache-pass-phrase-dialogs/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 06:14:51 +0000</pubDate>
		<dc:creator>Patrick</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://blog.nachtarbeiter.net/?p=832</guid>
		<description><![CDATA[Throughout the internet, HTTPS is used to encrypt traffic between a web server and its clients and thus provide a secure way of communicating with a server. Unfortunately, the best encryption is (somewhat) worthless, if you can&#8217;t be 100 percent sure that you are communicating with the right server. If Alice wants to send her [...]]]></description>
			<content:encoded><![CDATA[<p>Throughout the internet, <abbr title="Hypertext Transfer Protocol Secure">HTTPS</abbr> is used to encrypt traffic between a web server and its clients and thus provide a secure way of communicating with a server. Unfortunately, the best encryption is (somewhat) worthless, if you can&#8217;t be 100 percent sure that you are communicating with the right server. If <a href="http://en.wikipedia.org/wiki/Alice_and_Bob">Alice</a> wants to send her credit card number to Bob, all encryption is worthless, if Mallory can trick her into thinking that he is Bob. <abbr title="Secure Sockets Layer">SSL</abbr> certificates to the rescue. If Alice trusts Carol and Carol has issued a <abbr title="Secure Sockets Layer">SSL</abbr> certificate to Bob, Alice can be sure that Bob is actually Bob and not someone else. <abbr title="Secure Sockets Layer">SSL</abbr> certificates are usually protected by private keys. You need the private key to use the <abbr title="Secure Sockets Layer">SSL</abbr> certificate. These private keys are usually encrypted with a pass-phrase. If Mallory manages to compromise Bobs server and steal the private key file, he can not (mis-)use it, because it is encrypted. That&#8217;s the theory.</p>
<p>However, Bobs web server needs to read the private key file to utilize the <abbr title="Secure Sockets Layer">SSL</abbr> certificate. If it is encrypted, Bob has to either store the pass-phrase somewhere or enter it by hand every time he starts the web server. If Bob uses <cite>Apache</cite>, he will get a so-called pass-phrase dialog. By default it looks like this (on the command line):  </p>
<ol class="code">
<li><code>https-www:/etc/apache2-itk/# /etc/init.d/apache2-itk start</code></li>
<li><code>Some of your private key files are encrypted for security reasons.</code></li>
<li><code>In order to read them you have to provide the pass phrases.</code></li>
<li><code> </code></li>
<li><code>Server secure.example.org:443 (RSA)</code></li>
<li><code>Enter pass phrase:</code></li>
<li><code> </code></li>
<li><code>OK: Pass Phrase Dialog successful.</code></li>
<li><code>.</code></li>
</ol>
<p>While entering the pass-phrase of an <abbr title="Secure Sockets Layer">SSL</abbr> certificate by hand is a very secure approach, it has its share of problems:</p>
<ul>
<li>Upon reboot of Bobs server, the web server will not start automatically. It will hang, because it waits for the pass-phrase to be entered. Likewise, if the web server is restarted automatically for some reason (e.g. by monitoring software) the web server will hang on start-up, because it waits for the pass-phrase to be entered.</li>
<li>For security reasons, it is unwise to use the same pass-phrase for all private keys. Also, Bob shouldn&#8217;t use overly simple pass-phrases, that are easy to remember. If Bob needs tenths (or even hundreds) of private keys he can&#8217;t possibly remember every single pass-phrase.</li>
<li>It takes some time until Bob has looked up the corresponding pass-phrase in his mind or in his secure pass-phrase store. Even if he manages to immediately know every pass-phrase in use at his web server, it takes some time until he has entered the pass-phrase.</li>
</ul>
<p>For the sacrifice of some security, you can mitigate these issues. If you really don&#8217;t care much for security, you can either not use a pass-phrase in the first place or &#8211; if you somehow entered a pass-phrase by accident &#8211; remove the pass-phrase from the key file. To remove the pass-phrase from an <abbr title="Rivest Shamir Adleman encryption algorithm">RSA</abbr> private key use:</p>
<ol class="code">
<li><code>openssl rsa -in secure.example.org-2009.key -out secure.example.org-2009.key.unprotected</code></li>
</ol>
<p>If you want a somewhat more secure approach (depending on the implementation), you can check out the <a href="http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslpassphrasedialog"><code>SSLPassPhraseDialog</code> directive</a> of the <cite>Apache</cite> <code>mod_ssl</code> module. Using this directive, you can tell <cite>Apache</cite> to ask an external script for the pass-phrase of your certificates:</p>
<ol class="code">
<li><code>SSLPassPhraseDialog exec:/path/to/script</code></li>
</ol>
<p><cite>Apache</cite> will supply two arguments to the script. The first argument is of the form <code>servername:portnumber</code>, e.g. <code>secure.example.org:443</code> and the second argument is either <code>RSA</code> or <code>DSA</code>. The script would print the corresponding pass-phrase to <code>stdout</code>. Of course, you still need to store the pass-phrases somewhere. How much security you sacrifice using this construct depends on the implementation of your external script. But it might be a slight bit more secure than just using no pass-phrase for the private key files at all.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.nachtarbeiter.net/2009/08/20/getting-rid-of-apache-pass-phrase-dialogs/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

