<?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>langui.sh &#187; apache</title>
	<atom:link href="http://langui.sh/tag/apache/feed/" rel="self" type="application/rss+xml" />
	<link>http://langui.sh</link>
	<description>Fun hacks, WP plugins, photography, and PKI junk.  Languishing since 2008.</description>
	<lastBuildDate>Tue, 20 Jul 2010 22:12:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>SSL VHosting On The Same IP (aka SNI)</title>
		<link>http://langui.sh/2009/11/03/ssl-vhosting-on-the-same-ip-aka-sni/</link>
		<comments>http://langui.sh/2009/11/03/ssl-vhosting-on-the-same-ip-aka-sni/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 21:01:54 +0000</pubDate>
		<dc:creator>Paul Kehrer</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[sni]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://langui.sh/?p=747</guid>
		<description><![CDATA[Server Name Indication (SNI), an extension to TLS, allows browsers that support it to connect to SSL hosts that do not have dedicated IPs (much like standard http virtual hosting has worked for years). This extension, however, must be supported on both the server and client side. Microsoft has not yet chosen to support it [...]]]></description>
			<content:encoded><![CDATA[<p>Server Name Indication (SNI), an extension to TLS, allows browsers that support it to connect to SSL hosts that do not have dedicated IPs (much like standard http virtual hosting has worked for years).  This extension, however, must be supported on both the server and client side.  Microsoft has not yet chosen to support it (maybe IIS 8?), but the Apache project did with the 2.2.12 release.  Recently, Ubuntu 9.10 Server became the first server distribution to ship with Apache and OpenSSL built with the appropriate flags, so if you&#8217;d like to follow along you can use a 9.10 VM.</p>
<p>In the ideal case everything is the same as a regular vhost, but you&#8217;ll first need to enable SSL.  On Ubuntu this requires you to run <b>a2enmod</b> and type &#8220;ssl&#8221;.  After that you&#8217;ll need to add</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">443</span></pre></div></div>

<p>to the root conf, then make your VirtualHost much like a normal one.  A very basic pair of vhosts is seen below.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">443</span>&gt;
	<span style="color: #00007f;">ServerAdmin</span> webmaster@localhost
&nbsp;
	<span style="color: #00007f;">DocumentRoot</span> /my/doc/root
	<span style="color: #00007f;">ServerName</span> mydomain.com
	SSLEngine <span style="color: #0000ff;">On</span>
	SSLCertificateFile /path/to/domain.crt 
	SSLCertificateKeyFile /path/to/domain.key
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">443</span>&gt;
	<span style="color: #00007f;">ServerAdmin</span> webmaster@localhost
&nbsp;
	<span style="color: #00007f;">DocumentRoot</span> /my/doc/root
	<span style="color: #00007f;">ServerName</span> mydomain2.com
	SSLEngine <span style="color: #0000ff;">On</span>
	SSLCertificateFile /path/to/domain2.crt 
	SSLCertificateKeyFile /path/to/domain2.key
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<p>These vhosts should be placed in different includes ideally, but it isn&#8217;t required.  If you just want to test with a self-signed certificate you can create one with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-nodes</span> <span style="color: #660033;">-keyout</span> mykey.key <span style="color: #660033;">-out</span> mycert.cer <span style="color: #660033;">-days</span> <span style="color: #000000;">3650</span> <span style="color: #660033;">-x509</span></pre></div></div>

<p>You&#8217;ll need to specify the domain name you want in the &#8220;Common Name&#8221; section.</p>
<p>Once you&#8217;ve got all this done you can restart apache and test it out!  If you test on a browser that doesn&#8217;t support SNI (IE on XP) you&#8217;ll get the SSL cert for the first vhost apache parses.  To disable accessing it on non-SNI hosts you can add</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">SSLStrictSNIVHostCheck <span style="color: #0000ff;">on</span></pre></div></div>

<p>to the root conf.  This will cause a 403 error for those browsers.</p>
<p>If you&#8217;d like to see an example implementation of SNI you can check out my IDN domains <a href="http://xn--j4h.ws">https://☢.ws/</a> and <a href="https://xn--k4h.ws/">https://☣.ws/</a>.  These sites are hosted on the same IP with different SSL certificates.  I have strict host checking turned on so visiting them with a non-SNI capable browser will result in a 403 error.<sup class='footnote'><a href='#fn-747-1' id='fnref-747-1'>1</a></sup>
<div class='footnotes'>
<div class='footnotedivider'></div>
<ol>
<li id='fn-747-1'>See the Wikipedia article about <a href="http://en.wikipedia.org/wiki/Server_Name_Indication">Server Name Indication</a> for more information on supported browsers. <span class='footnotereverse'><a href='#fnref-747-1'>&#8617;</a></span></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://langui.sh/2009/11/03/ssl-vhosting-on-the-same-ip-aka-sni/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
