


<?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>CantRemembrances &#187; Site</title>
	<atom:link href="http://blog.cantremember.com/category/site/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.cantremember.com</link>
	<description>Memes of a technical vein discovered during CantRemember.com implementation</description>
	<lastBuildDate>Tue, 16 Feb 2010 06:36:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Easy delivery with mstmp and GMail</title>
		<link>http://blog.cantremember.com/easy-delivery-with-mstmp-and-gmail/</link>
		<comments>http://blog.cantremember.com/easy-delivery-with-mstmp-and-gmail/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 02:00:57 +0000</pubDate>
		<dc:creator>dfoley</dc:creator>
				<category><![CDATA[Site]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[msmtp]]></category>

		<guid isPermaLink="false">http://blog.cantremember.com/?p=64</guid>
		<description><![CDATA[At the moment, I really don&#8217;t feel like setting up a full-fledged MTA such as sendmail, postfix or qmail.  I want to take the simple course, basically because I&#8217;m lazy.  Fortunately, there are a variety of simple SMTP &#8216;relays&#8217; out there such as ssmtp and esmtp.  Some network officianatos may consider this [...]]]></description>
			<content:encoded><![CDATA[<p>At the moment, I really don&#8217;t feel like setting up a full-fledged MTA such as <a href="http://www.sendmail.org/">sendmail</a>, <a href="http://www.postfix.org/">postfix</a> or <a href="http://www.qmail.org/top.html">qmail</a>.  I want to take the simple course, basically because I&#8217;m lazy.  Fortunately, there are a variety of simple SMTP &#8216;relays&#8217; out there such as <a href="http://packages.debian.org/unstable/mail/ssmtp">ssmtp</a> and <a href="http://esmtp.sourceforge.net/">esmtp</a>.  Some network officianatos may consider this to be re-inventing the wheel, but then again, I&#8217;m sure glad that my car doesn&#8217;t roll on stone cylinders.</p>
<p>After some consideration, I chose to go with <a href="http://msmtp.sourceforge.net/"><strong>msmtp</strong></a>.  I like its flexible configuration, and it&#8217;s just the right size for the job (with room to grow).  The major thing I was looking for was STARTTLS support.  I wasn&#8217;t so concerned with the trust files and certificates, I just had a need to support GMail&#8217;s minimum requirements.  Yes, msmtp gives you that <em>and</em> the whole 9 yards, for when I need them all.</p>
<h3>msmtp Configuration for GMail</h3>
<p>With a combination of their official <a href="http://msmtp.sourceforge.net/doc/msmtprc.txt">configuration example</a> plus a few targeted suggestions from <a href="http://greybeardedgeek.net/?p=17">Grey Bearded Geek&#8217;s take at ssmtp</a>, I came up with the following:</p>
<div class="pre_wrap">
<pre><code># Set default values for all following accounts.
defaults

host  smtp.gmail.com
port  587
timeout  off
protocol  smtp
domain  localhost

# /usr/bin/msmtp --version
#  plain cram-md5 digest-md5 gssapi external login ntlm
auth  on
user  <strong>GMAIL-USER</strong>
password  <strong>GMAIL-PASSWD</strong>

tls  on
tls_starttls  on
# WARNING: When the checks are disabled, TLS/SSL sessions will be vulnerable to man-in-the-middle attacks
tls_certcheck  off

logfile  /var/log/msmtp.log
###syslog  on

# A system wide configuration is optional.
# If it exists, it usually defines a default account.
# This allows msmtp to be used like /usr/sbin/sendmail.
account default

# Construct envelope-from addresses of the form "user@oursite.example".
###auto_from on
from  <strong>USER@DOMAIN</strong>
maildomain  <strong>DOMAIN</strong></code></pre>
</div>
<p>You plop in the <code>GMAIL-USER</code> and <code>GMAIL-PASSWD</code>, and you&#8217;re good to go.</p>
<h3>Custom From: Address</h3>
<p>I soon learned that the <code>from</code> and <code>maildomain</code> settings are irrelevant; Google <a href="http://stackoverflow.com/questions/109520/rails-and-gmail-smtp-how-to-use-a-custom-from-address">will not arbitrarily change</a> the <code>From:</code> header of your mail.  That makes sense.  So the mail will appear as if it&#8217;s coming from you, <em>personally</em>.  Well, it turns out that there&#8217;s a few things you can do to get around that.</p>
<ul>
<li>Create yourself a <em>dedicated GMail account</em>.  Now you have isolated your soon-to-be-wildly-popular start-up&#8217;s e-mail account from your personal one.</li>
<li>Follow the instructions on <a href="http://mail.google.com/support/bin/answer.py?ctx=gmail&amp;hl=en&amp;answer=22370">adding a custom From: address to your account</a>.  I had to use the older version of the GMail interface to do so.  Google will verify that you own the address &#8212; you&#8217;d better be able to receive mail at that address &#8212; and then you can make it your default.
<p>GMail will now send your mail as it were coming from that address, but it will do so without providing an alias.</li>
<li>When sending your outbound mail, you can include the following headers:
<div class="pre_wrap">
<pre><code>From:  <strong>ALIAS</strong>
Reply-To:  <strong>ALIAS &lt;USER@DOMAIN</strong>&gt;</code></pre>
</div>
<p>Google will respect the <code>ALIAS</code> portion of the <code>From:</code> address, though not the address <em>itself</em>.  The <code>Reply-To:</code> is optional, but respected in its entirety (alias and address).</li>
</ul>
<p>Works like a charm.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cantremember.com/easy-delivery-with-mstmp-and-gmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wordpress and PmWiki under nginx</title>
		<link>http://blog.cantremember.com/wordpress-and-pmwiki-under-nginx/</link>
		<comments>http://blog.cantremember.com/wordpress-and-pmwiki-under-nginx/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 21:38:00 +0000</pubDate>
		<dc:creator>dfoley</dc:creator>
				<category><![CDATA[Site]]></category>
		<category><![CDATA[fcgi]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[pmwiki]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://blog.cantremember.com/?p=57</guid>
		<description><![CDATA[I recently double-checked my nginx configuration against the one that Elastic Dog has so proudly featured.  I&#8217;m very glad that I did &#8212; they provided me with a better understanding of the if / test capabilities of the syntax.
That being said, it still needed some adjustments &#8230;
WordPress
I&#8217;m currently running WordPress 2.7 under nginx 0.7.27. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently double-checked my <a href="http://wiki.codemongers.com/Main">nginx</a> configuration against the one that <a href="http://elasticdog.com/2008/02/howto-install-wordpress-on-nginx/">Elastic Dog</a> has so proudly featured.  I&#8217;m very glad that I did &#8212; they provided me with a better understanding of the if / test capabilities of the syntax.</p>
<p>That being said, it still needed some adjustments &#8230;</p>
<h3>WordPress</h3>
<p>I&#8217;m currently running <a href="http://wordpress.com">WordPress</a> 2.7 under nginx 0.7.27.  Here&#8217;s my end configuration:</p>
<div class="pre_wrap">
<pre><code>server {
	include  extra/proxy.conf;
	include  mime.types;

	listen  80;
	server_name  blog.<strong>DOMAIN.NAME</strong>;

	access_log  logs/<strong>LOGFILE</strong>-access.log;
	###error_log  logs/LOGFILE-error.log  debug;
	error_log  logs/LOGFILE-error.log;

	# Settings | General | WordPress address (URL)
	location /<strong>WP-CONTEXT</strong> {
		# physical location on server
		root  /<strong>PATH/TO/WP-DIR</strong>;
		index  index.php index.html index.htm;

		# remove virtual path, make it root-relative
		rewrite  ^/<strong>WP-CONTEXT</strong>(.*)$  $1;

		# this serves static files that exist without running other rewrite tests
		if (-f $request_filename) {
			expires 30d;
			break;
		}

		# addresses '/wp-admin/' and similar vein
		if (-f $request_filename/index.php) {
			# produces '...//index.php', acceptable loss
			rewrite  ^(.+)$  /<strong>WP-CONTEXT</strong>$1/index.php  last;
		}

		# this sends all non-existing file or directory requests to index.php
		if (!-e $request_filename) {
			rewrite  ^(.+)$  /<strong>WP-CONTEXT</strong>/index.php?q=$1  last;
		}
	}

	location ~ \.php$ {
		# remove virtual path, make it root-relative
		rewrite  ^/<strong>WP-CONTEXT</strong>(.*)$  $1;

		fastcgi_pass  fastcgi_cluster;
		fastcgi_index index.php;
		# physical location on server
		fastcgi_param SCRIPT_FILENAME /<strong>PATH/TO/WP-DIR</strong>$fastcgi_script_name;
		include  fastcgi_params;
	}

	# Settings | General | Blog address (URL)
	location / {
		# WordPress handles this perfectly as-is
		fastcgi_pass  fastcgi_cluster;
		# physical location on server
		fastcgi_param SCRIPT_FILENAME /<strong>PATH/TO/WP-DIR</strong>/index.php;
		include  fastcgi_params;
	}
}</code></pre>
</div>
<p>I&#8217;ll provide the content of <code>extra/proxy.conf</code> and <code>fastcgi_params</code> down below &#8212; they won&#8217;t surprise you &#8212; plus the configuration for my upstream <code>fastcgi_cluster</code>.</p>
<p>The purpose of <code>DOMAIN.NAME</code> and <code>LOGFILE</code> is obvious, so let&#8217;s skip to the useful stuff.</p>
<h4><code>/PATH/TO/WP-DIR</code></h4>
<p>This is simply the fully-qualified path to the directory where you have installed WordPress.  Big shock, I know.  I put mine in &#8216;/var/www/wordpress&#8217;.</p>
<h4><code>WP-CONTEXT</code></h4>
<p>Specifically, I&#8217;m referencing the <em>&#8216;WordPress address (URL)&#8217;</em> capture block.</p>
<p>Wordpress 2.7 <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">supports a differentiation</a> between the root context of your blog and the root context of the WordPress resources themselves.  I&#8217;ve taken this approach &#8230; the URL of this blog post is root-relative to my virtual hostname, but if you do a View Source you&#8217;ll see:</p>
<div class="pre_wrap">
<pre><code>&lt;link rel="stylesheet" href="http://blog.cantremember.localhost/<strong>wordpress</strong>/wp-content/themes/cantremember/style.css" type="text/css" media="screen" /&gt;
...
&lt;link rel="pingback" href="http://blog.cantremember.localhost/<strong>wordpress</strong>/xmlrpc.php" /&gt;</code></pre>
</div>
<p>It&#8217;s a nice-to-have, and in many ways allows the configuration to be somewhat easier.  In WordPress Admin, under <em>Settings | General</em>, I have configured:</p>
<ul>
<li><em>WordPress address (URL)</em> = http://blog.cantremember.localhost/wordpress</li>
<li><em>Blog address (URL)</em> = http://blog.cantremember.localhost</li>
</ul>
<p>So my <code>WP-CONTEXT</code> is &#8216;wordpress&#8217;.  </p>
<h4>Usage</h4>
<p>Here are the core differentiations between my config and the Elastic Dog one:</p>
<p>My core two sections are the ones with <code>WP-CONTEXT</code>.  Before doing anything, I make the <code>$request_filename</code> context-less, so that it&#8217;s corrected relative to root.  Granted, I could have skipped that step because I used &#8216;wordpress&#8217; for each, but that doesn&#8217;t make for as good an example, and regex&#8217;s aren&#8217;t that expensive (don&#8217;t they have dedicated chips for them by now?).</p>
<p>I was having issues when WordPress wanted to take me to the Admin screen.  It used the shortcut &#8216;<code>/WP-CONTEXT/wp-admin</code>&#8216;, which is great if you&#8217;re not doing all this fancy re-writing and <code>fastcgi_index</code> can take over.  But we <em>are</em> being fancy.  That&#8217;s why the <code>$request_filename/index.php</code> text exists.  It works like a charm, although there may be a more efficient way to do this.</p>
<p>And here is where it became an advantage to differentiate between blog URLs and WordPress resources.  I&#8217;ve chosen to make my permalinks dateless &#8212; <code>/%postname%/</code> .  Call me crazy, but I like the way it looks on <a href="http://laughingsquid.com/bush-street-renamed-obama-street-in-san-francisco/">Laughing Squid</a>.  Given that&#8217;s the case, it&#8217;s hard to differentiate between &#8216;/some-permalink/&#8217; and &#8216;/wp-admin/&#8217;.  Splitting them off with the &#8216;wordpress&#8217; context made this possible.</p>
<p>The final context-less <em>&#8216;Blog address (URL)&#8217;</em> capture block is exactly what you&#8217;d expect.</p>
<h3>PmWiki</h3>
<p>I liked the simplicity and capabilities of <a href="http://www.pmwiki.org/">PmWiki</a> 2.2.0.  It&#8217;s an easier decision, since I have no intention of being a grand-scale collective document facility.  PmWiki is a powerful and flexible implementation with a lot of great processing directives that you can embed in a page.  Yet that also makes security something of a concern (as <a href="http://www.shlomifish.org/philosophy/computers/web/which-wiki/update-2006-07/#pmwiki">some reviewers</a> will point out as well).  Global multi-tier <a href="http://www.pmwiki.org/wiki/PmWiki/PasswordsAdmin">password auth</a> is available, and <a href="http://www.pmwiki.org/wiki/PmWiki/AuthUser">user-based auth</a> is available as necessary.</p>
<p>This configuration is a natural extension of the WordPress one above:</p>
<div class="pre_wrap">
<pre><code>server {
	include  extra/proxy.conf;
	include  mime.types;

	listen  80;
	server_name  wiki.<strong>DOMAIN.NAME</strong>;

	access_log  logs/<strong>LOGFILE</strong>-access.log;
	###error_log  logs/LOGFILE-error.log  debug;
	error_log  logs/LOGFILE-error.log;

	# PHP execution only
	location ~ \.php$ {
		fastcgi_pass  fastcgi_cluster;
		fastcgi_index pmwiki.php;
		# physical location on server
		fastcgi_param SCRIPT_FILENAME /<strong>PATH/TO/PMWIKI-DIR</strong>$fastcgi_script_name;
		include  fastcgi_params;
	}

	location / {
		# physical location on server
		root  /<strong>PATH/TO/PMWIKI-DIR</strong>;
		index  index.php index.html index.htm;

		# this serves static files that exist without running other rewrite tests
		if (-f $request_filename) {
			expires 30d;
			break;
		}

		# this sends all non-existing file or directory requests to index.php
		if (!-e $request_filename) {
			# ? =&gt; &amp;, then remove the leading /
			rewrite  ^(.*)\?(.*)$  $1&amp;$2;
			rewrite  ^/(.+)$  /?n=$1  last;
		}
	}
}</code></pre>
</div>
<p>Everything here is obvious, including <code>/PATH/TO/PMWIKI-DIR</code>.  Mine is &#8216;/var/www/pmwiki&#8217;.  Here&#8217;s the lowdown:</p>
<p>In the <code>*.php</code> capture block, you&#8217;ll see that the default script is <code>pmwiki.php</code>.  I had created a symlink to rename it <code>index.php</code>, but after my config re-adjustment, that became obsolete.</p>
<p>The non-existing file test will be triggered by the following requests:</p>
<ul>
<li>/Main/HomePage</li>
<li>/Main/HomePage?action=edit</li>
</ul>
<p>Those URLs exist because I&#8217;m leveraging a feature called <a href="http://www.pmwiki.org/wiki/PmWiki/LayoutVariables#EnablePathInfo"><code>$EnablePathInfo</code></a>.  The referenced documentation doesn&#8217;t do it justice &#8230; this feature allows me to have bare <em>Group/Name</em> URLs, much like I&#8217;m doing with my bare blog URLs.  I&#8217;ll just say that I&#8217;m being SEO-minded and leave it at that.</p>
<p>Turning on that feature informs PmWiki to generate the URLs in that format, and it also makes the PHP script capable of parsing the CGI headers to do-the-right-thing.  My original configuration required me to perform the following override hack:</p>
<div class="pre_wrap">
<pre><code>include  fastcgi_params;
fastcgi_param SCRIPT_NAME '';</code></pre>
</div>
<p>But the revised configuration above simply re-writes the URL into the standard <code>'?n=</code>&#8216; format and the script never has to deal with CGI headers.  The only other rewrite considerations were to transform any querystring &#8216;?&#8217; into &#8216;&amp;&#8217; and to remove the leading &#8216;/&#8217; from the <em>Group/Name</em> combo.</p>
<p>Hooray!</p>
<h3>Supporting Configuration</h3>
<p>For all means and purposes, I&#8217;m using nginx&#8217;s default <code>fastcgi_params</code>.</p>
<p>This is <code>extra/proxy.conf</code>, derived from their <a href="http://wiki.codemongers.com/NginxFullExample">NginxFullExample</a>, with notes-to-self intact:</p>
<div class="pre_wrap">
<pre><code># can't set this here!
###proxy_redirect          default;

proxy_set_header        Host            $host;
proxy_set_header        X-Real-IP       $remote_addr;
proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

#client_max_body_size    10m;
#client_body_buffer_size 128k;

proxy_connect_timeout   15;
proxy_send_timeout      90;
proxy_read_timeout      30;

# turn off for Comet!
proxy_buffering         on;
proxy_buffers           32 8k;

proxy_ignore_client_abort  on;

# for caching, via Last-Modified:
#proxy_store          on;
#proxy_store_access   user:rw  group:rw  all:r;
#proxy_temp_path      /data/temp;</code></pre>
</div>
<p>This is <em>fastcgi_cluster</em>, which is just a simple example of how to do clustering:</p>
<div class="pre_wrap">
<pre><code>upstream fastcgi_cluster {
	# sticky by IP
	###ip_hash;

	# max_fails=3  fail_timeout=15s  weight=2
	# down  backup
	server  127.0.0.1:<strong>PORT-1</strong>;
	server  127.0.0.1:<strong>PORT-2</strong>;
	server  127.0.0.1:<strong>PORT-3</strong>;
}</code></pre>
</div>
<p>I tried using some of the additional server setting features &#8212; commented out above &#8212; but they weren&#8217;t working in my build of 0.7.27.  I can live without them at the moment, but the upstream block capabilities are quite powerful.</p>
<p>I&#8217;m running 3 FastCGI instances, each with 5 worker threads.  Again, good enough for government work.  I custom-built <code>fcgi</code> on OS X, but for my <a href="http://aws.amazon.com">AWS</a> Fedora Core 8 image I just went with <code>spawn-fcgi</code> that comes along with the <code><a href="http://www.lighttpd.net/">lighttpd</a></code> package.</p>
<p>This cluster config is also a nice starter reference for adding load-balancing capabilities to external AWS instances.  Given the volatile nature of VM image mappings, I&#8217;ve split the cluster config off into its own file for scripted generation.</p>
<h3>In Summary</h3>
<p>I&#8217;m very pleased with nginx.  It has been very stable &#8212; the only time I&#8217;ve taken it down is when setting it up for infinte <code>HTTP 302</code> redirects, and even then it took several hours of user activity to knock it over.  The configuration syntax is very powerful, and I haven&#8217;t once been wistful for my old <a href="http://httpd.apache.org/">Apache</a> habits :) .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cantremember.com/wordpress-and-pmwiki-under-nginx/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Beginning</title>
		<link>http://blog.cantremember.com/the-beginning/</link>
		<comments>http://blog.cantremember.com/the-beginning/#comments</comments>
		<pubDate>Tue, 13 Jan 2009 01:24:17 +0000</pubDate>
		<dc:creator>dfoley</dc:creator>
				<category><![CDATA[Site]]></category>
		<category><![CDATA[cloud]]></category>

		<guid isPermaLink="false">http://blog.cantremember.com/?p=5</guid>
		<description><![CDATA[a good place to start.
i&#8217;ve been holding the CantRemember.com domain for years now, mostly so that i&#8217;d have awesome e-mail address.  now, the time has come to do something with it. something is the operative term
this site exists to host my fun projects. i have some in mind, but i don&#8217;t like to make [...]]]></description>
			<content:encoded><![CDATA[<p>a good place to start.</p>
<p>i&#8217;ve been holding the <a href="http://cantremember.com">CantRemember.com</a> domain for years now, mostly so that i&#8217;d have awesome e-mail address.  now, the time has come to do something with it. <em>something</em> is the operative term</p>
<p>this site exists to host my fun projects. i have some in mind, but i don&#8217;t like to make promises. the <a href="http://wiki.cantremeber.com">wiki</a> is my central source of documentation, and this blog gives me a channel for constructive output. initial thanks go out to:</p>
<ul>
<li><a href="http://aws.amazon.com/">Amazon Web Services</a></li>
<li>the <a href="http://rubyforge.org/projects/amazon">aws-s3</a>, <a href="http://github.com/grempe/amazon-ec2/tree/master">amazon-ec2</a> and <a href="http://rubyforge.org/projects/net-ssh">net-ssh</a> gems</li>
<li><a href="http://wiki.codemongers.com/Main">nginx</a>, and <a href="http://www.lighttpd.net/">lighttpd</a>&#8217;s FastCGI impl</li>
<li><a href="http://www.pmwiki.org/">Pmwiki</a></li>
<li>Wordpress, and the <a href="http://zitseng.com/">Simplicity</a> theme</li>
</ul>
<p>plus countless other blogs and threads. i&#8217;m now going to spend a few initial posts catching up on things that i learned while i was doing all this setup. hopefully it will be useful to others :)</p>
<p>sit back and relax. enjoy the show</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.cantremember.com/the-beginning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
