<?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>dragffy.com &#187; ssl</title>
	<atom:link href="http://dragffy.com/blog/posts/tag/ssl/feed" rel="self" type="application/rss+xml" />
	<link>http://dragffy.com/blog</link>
	<description>The development, documentation, and blogging domain of Gabriel Dragffy.</description>
	<lastBuildDate>Sun, 29 Apr 2012 11:55:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Apache 2 with SSL on FreeBSD 6</title>
		<link>http://dragffy.com/blog/posts/apache-2-with-ssl-on-freebsd-62</link>
		<comments>http://dragffy.com/blog/posts/apache-2-with-ssl-on-freebsd-62#comments</comments>
		<pubDate>Mon, 15 Oct 2007 15:30:37 +0000</pubDate>
		<dc:creator>Gabe</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[guide]]></category>
		<category><![CDATA[ssl]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://dragffy.com/blog/articles/apache-2-with-ssl-on-freebsd-62</guid>
		<description><![CDATA[It wasn&#8217;t exactly trivial installing and configuring Apache 2 on FreeBSD. Much of the configuration had to be done manually, which depending on your point-of-view is good or bad. This describes how I went about getting Apache 2 with SSL support up and running on FreeBSD 6. I did this on 6.2 but it should [...]]]></description>
			<content:encoded><![CDATA[<p>It wasn&#8217;t exactly trivial installing and configuring Apache 2 on FreeBSD. Much of the configuration had to be done manually, which depending on your point-of-view is good or bad. This describes how I went about getting Apache 2 with SSL support up and running on FreeBSD 6. I did this on 6.2 but it should equally apply to  6.x.<span id="more-3"></span></p>
<p>Note: These instructions use &#8220;www.example.com&#8221; as an example.</p>
<p>To Install Apache2:</p>
<p>After the UpdatePorts, install apache2 as follows:</p>
<p><code> cd /usr/ports/www/apache2 </code></p>
<pre>make install clean</pre>
<p>Enable Apache2 in <code>/etc/rc.conf</code> by adding the following&#8230;<br />
<code> </code></p>
<pre>apache2_enable="YES"

apache2ssl_enable="YES"</pre>
<p>Setup the certificates:</p>
<pre>mkdir /usr/local/etc/apache2/ssl.crt

mkdir /usr/local/etc/apache2/ssl.key</pre>
<p>Edit <code>/usr/local/etc/apache2/ssl.conf</code> and set the following&#8230;</p>
<pre>SSLCertificateFile /usr/local/etc/apache2/ssl.crt/server.crt

SSLCertificateKeyFile /usr/local/etc/apache2/ssl.key/server.key</pre>
<p>After saving the certificates in their appropriate directories run:</p>
<p><code>chmod -R 700 /usr/local/etc/apache2/ssl.key</code></p>
<p>Edit <code>/usr/local/etc/apache2/httpd.conf</code> and set the following:</p>
<pre>ServerAdmin mshurst@engmail.uwaterloo.ca
UseCanonicalName On
DocumentRoot "/homepages"
UserDir disabled
ServerSignature Off</pre>
<p>In <code>&lt;Directory "/homepages"&gt;</code> set&#8230;</p>
<pre>Options FollowSymlinks Multiview Includes ExecCGI

AllowOverride All</pre>
<p>Comment out the <code>&lt;Directory /home/*/public_html&gt;</code> section and replace it with&#8230;</p>
<pre>&lt;Directory /u1/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;

&lt;Directory /u2/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;

&lt;Directory /u3/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;

&lt;Directory /u4/*/public_html&gt;
   Options All -Indexes
   AllowOverride All
   Order allow,deny
   Allow from all
&lt;/Directory&gt;</pre>
<p>Restart apache2 to start using the new certificate&#8230;</p>
<p><code><br />
/usr/local/etc/rc.d/apache2.sh stop<br />
/usr/local/etc/rc.d/apache2.sh start<br />
</code></p>
<p>To enable CGIWrap<br />
Allows execution of cgi scripts using user permissions</p>
<p>To install cgiwrap&#8230;</p>
<pre>cd /usr/ports/www/cgiwrap
make
make install</pre>
<p>Add AddHandler cgi-script .cgi to <code>/usr/local/etc/apache2/httpd.conf</code>.</p>
<p>Access control files are required for cgiwrap. To allow open access&#8230;</p>
<p><code>touch /usr/local/etc/cgiwrap.deny</code></p>
<p>To enable the &#8220;debug&#8221; version of cgiwrap&#8230;</p>
<p><code>chmod 4755 /usr/local/www/cgi-bin/cgiwrapd</code></p>
<p>In <code>&lt;Directory "/usr/local/www/cgi-bin"&gt;</code> set&#8230;</p>
<pre>  <code>Options ExecCGI</code></pre>
<p>To restrict &#8220;debug&#8221; access to on-campus only, add the following to httpd.conf&#8230;</p>
<p><code> &lt;Location /cgi-bin/cgiwrapd&gt; </code></p>
<pre>     order deny,allow
     deny from all
     allow from 129.97
&lt;/Location&gt;

&lt;Location /cgi-bin/nph-cgiwrapd&gt;
     order deny,allow
     deny from all
     allow from 129.97
&lt;/Location&gt;</pre>
<p>To enable Server Side Includes<br />
Allows server side parsing of html files.</p>
<p>Make the following changes in <code>/usr/local/etc/apache2/httpd.conf</code>&#8230;</p>
<p>uncomment (or add)</p>
<p><code>AddType text/html .shtml</code></p>
<p><code>AddHandler server-parsed .shtml</code></p>
<p>Allow <code>index.shtml</code> to be a default page</p>
<p><code>DirectoryIndex index.html ... index.shtml</code></p>
<p>Add the &#8220;Includes&#8221; option</p>
<p><code>Options Indexes FollowSymLinks MultiViews ExecCGI Includes</code></p>
<p><strong>Customized Virtual Host settings</strong></p>
<pre>   * Make the following changes to <code>/usr/local/etc/apache2/ssl.conf</code>...</pre>
<pre>#&lt;VirtualHost _default_:443&gt;

&lt;VirtualHost www.eng.uwaterloo.ca:443&gt;
DocumentRoot "/homepages"
ServerName www.eng.uwaterloo.ca

ServerAdmin mshurst@engmail.uwaterloo.ca</pre>
<pre>   * Configure logging to include the virtual host name by adding %v to the end of the LogFormat entry in httpd.conf</pre>
<p><code>LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\" %v" combined</code></p>
<pre>   * Add the following CustomLog entry to the www.example.com virtual host entry.</pre>
<p><code>CustomLog /var/log/httpd-sydewww.log combined</code></p>
<pre>   * Update the <code>rollapachelogs.csh</code> script to include the <code>httpd-sydewww.log</code> files.</pre>
<p>==<br />
Rolling the Apache logs ==<br />
The logs must be rolled occasionally to prevent the disk from filling with logs. This isn&#8217;t as trivial as it should be, because:</p>
<pre>   * If you roll the logs, and send a SIGTERM to httpd, all httpd processes will abort, possibly resulting in incomplete database updates etc

   * If you roll the logs, and send a SIGUSR1 to httpd, you must wait some unknown period of time to allow all child httpd processes to complete, before compressing logs.</pre>
<p>Alternatives:</p>
<pre>   * Don't compress the logs, and use newsyslog with signal 30 (USR1)

   * pipe the logs in httpd.conf through some other process

   * use a custom log roller script</pre>
<p>To do the latter, run:</p>
<p><code> fetch -o /usr/local/bin/rollapachelogs.csh <a href="http://www.freebsd.uwaterloo.ca/rollapachelogs.csh" class="external free" title="http://www.freebsd.uwaterloo.ca/rollapachelogs.csh" rel="nofollow">http://www.freebsd.uwaterloo.ca/rollapachelogs.csh</a></code></p>
<pre>chmod u+x /usr/local/bin/rollapachelogs.csh</pre>
<p>Add to <code>/etc/crontab</code>:<br />
<code> </code></p>
<pre># rotate apache logs

0       3       *       *       *       root    /usr/local/bin/rollapachelogs.csh</pre>
<p>Configuring Name-based virtual hosting</p>
<p>Set the folloowing in <code>/usr/local/etc/apache2/httpd.conf</code>&#8230;</p>
<p><code> NameVirtualHost *</code></p>
<pre># Default VirtualHost is listed here

# others are listed in /usr/local/etc/apache2/Includes/vhosts.conf

&lt;VirtualHost *&gt;
   ServerName www.eng.uwaterloo.ca
   ServerAlias www.eng
   DocumentRoot /homepages
   UserDir public_html
   ErrorDocument 403 /lookup.cgi
   ErrorDocument 404 /lookup.cgi
   ErrorDocument 410 /lookup.cgi
&lt;/VirtualHost&gt;</pre>
<p>Then add the other virtual hosts to <code>/usr/local/etc/apache2/Includes/vhosts.conf</code>&#8230;</p>
<pre>   ServerName www.engcomp.uwaterloo.ca
   ServerAlias www.engcomp www.engineeringcomputing.uwaterloo.ca www.engineeringcomputing
   DocumentRoot /u2/engcomp/public_html

   &lt;Directory /u2/engcomp/public_html&gt;      Options All
      AllowOverride All
      Order allow,deny
      Allow from all
   &lt;/Directory&gt;

   ScriptAlias /cgi-bin/ "/u2/eng_comp/public_html/cgi-bin/"
   &lt;Directory "/u2/eng_comp/public_html/cgi-bin/"&gt;
      AllowOverride None
      Options None
      Order allow,deny
      Allow from all
   &lt;/Direcotry&gt;</pre>
<p>Restrict access to printman pages</p>
<pre>&lt;Directory "/u2/eng_comp/public_html/printers"&gt;
   Order deny,allow
   Deny from all
   Allow from 129.97
&lt;/Directory&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://dragffy.com/blog/posts/apache-2-with-ssl-on-freebsd-62/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

