<?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>dan.thoughts &#187; sinatra</title>
	<atom:link href="http://blog.sosedoff.com/tag/sinatra/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sosedoff.com</link>
	<description>Web-development, PHP, Ruby, Sinatra, Merb, Rails, MySQL, SQLite, Web Services.</description>
	<lastBuildDate>Wed, 25 Jan 2012 18:54:45 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Discover hidden API services with Proxie</title>
		<link>http://blog.sosedoff.com/2011/01/25/discover-hidden-api-services-with-proxie/</link>
		<comments>http://blog.sosedoff.com/2011/01/25/discover-hidden-api-services-with-proxie/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 12:05:54 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[API's]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby Gems]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[http-proxy]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=343</guid>
		<description><![CDATA[Need to figure out closed/private API? Not a problem. Its always fun and challenging. There are few tools i use for that:

Firefox LiveHTTP Headers extension
Charles Web Debugging Proxy Application
Proxie

Proxie is another project of mine, which i finally extracted from a script written a while ago and published it as a ruby gem.
I used it to [...]]]></description>
			<content:encoded><![CDATA[<p>Need to figure out closed/private API? Not a problem. Its always fun and challenging. There are few tools i use for that:</p>
<ul>
<li><a href="https://addons.mozilla.org/en-us/firefox/addon/live-http-headers/">Firefox LiveHTTP Headers extension</a></li>
<li><a href="http://www.charlesproxy.com/">Charles Web Debugging Proxy Application</a></li>
<li><a href="https://github.com/sosedoff/proxie">Proxie</a></li>
</ul>
<p>Proxie is another project of mine, which i finally extracted from a script written a while ago and published it as a ruby gem.<br />
I used it to track Grooveshark API and it worked out great. Here is the list of features:</p>
<ul>
<li>Bind proxy server to any port (default is 8080)
<li>Define output database. It uses SQLite3 by default, but you can extend it with any other types</li>
<li>Sinatra-base web interface to browse all your collected data</li>
</ul>
<p>Installation:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> proxie</pre></div></div>

<p>Start a server:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">proxie <span style="color: #660033;">-d</span> DATABASE_NAME</pre></div></div>

<p>After data collection just run:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">proxie <span style="color: #660033;">--web</span></pre></div></div>

<p>The web interface runs on localhost:4567 by default.</p>
<p>Usage summary:</p>
<pre>
Usage: proxie [options]
    -i, --info                       Display this information.
    -p, --port PORT                  Listen on port (8080 default)
    -d, --db NAME                    Store results to database
    -w, --web                        Start a Web UI for databases
    -f, --flush                      Delete all local databases
</pre>
<p>Project on GitHub: <a href="http://github.com/sosedoff/proxie">http://github.com/sosedoff/proxie</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2011/01/25/discover-hidden-api-services-with-proxie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Why rapid development is the best way to make web apps</title>
		<link>http://blog.sosedoff.com/2010/09/17/why-rapid-development-is-the-best-way-to-make-web-apps/</link>
		<comments>http://blog.sosedoff.com/2010/09/17/why-rapid-development-is-the-best-way-to-make-web-apps/#comments</comments>
		<pubDate>Sat, 18 Sep 2010 02:27:30 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[rapid]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=275</guid>
		<description><![CDATA[What do you know about rapid development? 
I guess something. Almost every developer experienced moments when you or someone have really interesting idea and wanted to jump on it right away. One of the obstacles &#8211; tools you use to achieve it. And the web framework is the first of them. Why? Because if you [...]]]></description>
			<content:encoded><![CDATA[<p>What do you know about rapid development? </p>
<p>I guess something. Almost every developer experienced moments when you or someone have really interesting idea and wanted to jump on it right away. One of the obstacles &#8211; tools you use to achieve it. And the web framework is the first of them. Why? Because if you want to create something cool without being stuck on technology level you should use things that you dont really notice while making your app. Of course it varies from person-to-person, but just imagine yourself in traffic jam driving stick-shift car, switching gears like crazy all the time. </p>
<p>Back to webdev, with my experience i can only say that the best tool for rapid development is <a href="http://www.sinatrarb.com/">Sinatra</a>.  Its so small and powerful that i got hooked on it since first day i found it. Almost all my personal/work projects on early stages have been developed with Sinatra. Another big plus &#8211; small and usefull extensions, big players like <a href="http://ar.rubyonrails.org/">AR</a> or <a href="http://datamapper.org">DataMapper</a>. It was extracted from Merb project, another small and powerful web framework i like to work with. Its like a one-file web application. Perfect for super-fast development. Wanna do simple music downloads page? No problem. API &#8211; again, no problem. Deployment is simple and similar to most of frameworks, as it built on top of <a href="http://rack.rubyforge.org/">Rack</a>: thin, passenger (nginx/apache).</p>
<p>What do you know about rapid development?<br />
<strong>I say &#8211; i love it.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/09/17/why-rapid-development-is-the-best-way-to-make-web-apps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generate sitemaps with Ruby and XmlSitemap gem</title>
		<link>http://blog.sosedoff.com/2010/06/18/generate-sitemaps-with-ruby-and-xmlsitemap-gem/</link>
		<comments>http://blog.sosedoff.com/2010/06/18/generate-sitemaps-with-ruby-and-xmlsitemap-gem/#comments</comments>
		<pubDate>Fri, 18 Jun 2010 23:10:38 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[generation]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[sitemap]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=244</guid>
		<description><![CDATA[Made a simple gem for website sitemap generation. Could be used in any Ruby/Rails/Merb/Sinatra application. It does not have any caching in that case if you want to use framework built-in cache methods. 
Installation:

$ sudo gem install xml-sitemap

Example

pages = Page.all&#40;:order =&#62; &#91;:updated_at.desc&#93; # DM model
map = XmlSitemap::Map.new&#40;'somedomain.com'&#41; do &#124;m&#124;
  m.add&#40;:url =&#62; '/', :period =&#62; [...]]]></description>
			<content:encoded><![CDATA[<p>Made a simple gem for website sitemap generation. Could be used in any Ruby/Rails/Merb/Sinatra application. It does not have any caching in that case if you want to use framework built-in cache methods. </p>
<p>Installation:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> xml-sitemap</pre></div></div>

<h3>Example</h3>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">pages = Page.<span style="color:#9900CC;">all</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:order</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:updated_at</span>.<span style="color:#9900CC;">desc</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#008000; font-style:italic;"># DM model</span>
map = <span style="color:#6666ff; font-weight:bold;">XmlSitemap::Map</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'somedomain.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>m<span style="color:#006600; font-weight:bold;">|</span>
  m.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/'</span>, <span style="color:#ff3333; font-weight:bold;">:period</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:daily</span>, <span style="color:#ff3333; font-weight:bold;">:priority</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1.0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  m.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/contractors'</span>, <span style="color:#ff3333; font-weight:bold;">:period</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:daily</span>, <span style="color:#ff3333; font-weight:bold;">:priority</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">1.0</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  pages.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>p<span style="color:#006600; font-weight:bold;">|</span>
    m.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span>
      <span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> url_for_page<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0066; font-weight:bold;">p</span><span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:updated</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#CC0066; font-weight:bold;">p</span>.<span style="color:#9900CC;">updated_at</span>,
      <span style="color:#ff3333; font-weight:bold;">:priority</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">0.5</span>,
      <span style="color:#ff3333; font-weight:bold;">:period</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:never</span>
    <span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#008000; font-style:italic;"># render the sitemap</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> map.<span style="color:#9900CC;">render</span></pre></div></div>

<h3>Sinatra Example</h3>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># ... your code</span>
&nbsp;
get <span style="color:#996600;">'/sitemap.xml'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  map = <span style="color:#6666ff; font-weight:bold;">XmlSitemap::Map</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'domain.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>m<span style="color:#006600; font-weight:bold;">|</span>
    m.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    m.<span style="color:#9900CC;">add</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/posts'</span>, <span style="color:#ff3333; font-weight:bold;">:period</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:weekly</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  headers<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'Content-Type'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'text/xml'</span>
  map.<span style="color:#9900CC;">render</span>
<span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># ... more code</span></pre></div></div>

<h3>Options</h3>
<p>:url &#8211; page path, relative to domain (ex.: /test), String.<br />
:period &#8211; freqchange attribute, Symbol, :none, :never, :always, :hourly, :daily, :weekly, :monthly, :yearly<br />
:priority &#8211; priority attribute, Float class,(0.0..1.0)<br />
:updated &#8211; (optional) last_update attribute, Time class</p>
<h3>Source Code</h3>
<p><a href="http://github.com/sosedoff/xml-sitemap">http://github.com/sosedoff/xml-sitemap</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/06/18/generate-sitemaps-with-ruby-and-xmlsitemap-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to test mailers in Sinatra, Rails and Merb</title>
		<link>http://blog.sosedoff.com/2010/05/03/how-to-test-mailers-in-sinatra-rails-and-merb/</link>
		<comments>http://blog.sosedoff.com/2010/05/03/how-to-test-mailers-in-sinatra-rails-and-merb/#comments</comments>
		<pubDate>Tue, 04 May 2010 04:06:12 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[mailer]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[sinatra]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=203</guid>
		<description><![CDATA[Once you need to test mailers within your Sinara, Rails or Merb application you wish to see a real output. No need to setup delivery via SMTP. Just create an executable ruby script somewhere, for example: /usr/bin/fake-sendmail.sh with following content:

$ touch /usr/bin/fake-sendmail.sh 
$ chmod +x /usr/bin/fake-sendmail.sh  # make it executable (will require root priv.)


#!/usr/bin/ruby
path [...]]]></description>
			<content:encoded><![CDATA[<p>Once you need to test mailers within your Sinara, Rails or Merb application you wish to see a real output. No need to setup delivery via SMTP. Just create an executable ruby script somewhere, for example: /usr/bin/fake-sendmail.sh with following content:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>fake-sendmail.sh 
$ <span style="color: #c20cb9; font-weight: bold;">chmod</span> +x <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>fake-sendmail.sh  <span style="color: #666666; font-style: italic;"># make it executable (will require root priv.)</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/ruby</span>
path = <span style="color:#996600;">&quot;/tmp/fake-mailer&quot;</span>
<span style="color:#CC00FF; font-weight:bold;">Dir</span>.<span style="color:#9900CC;">mkdir</span><span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> !<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#9900CC;">exists</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>path<span style="color:#006600; font-weight:bold;">&#41;</span>
<span style="color:#CC00FF; font-weight:bold;">File</span>.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;#{path}/#{Time.now.to_i}.txt&quot;</span>, <span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span>
    f.<span style="color:#CC0066; font-weight:bold;">puts</span> ARGV.<span style="color:#9900CC;">inspect</span>
    <span style="color:#ff6633; font-weight:bold;">$stdin</span>.<span style="color:#9900CC;">each_line</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>line<span style="color:#006600; font-weight:bold;">|</span> f.<span style="color:#CC0066; font-weight:bold;">puts</span> line <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And then configure your mailing system:</p>
<h3>1. Sinatra</h3>
<p>There is a plugin for Sinatra (ported from Merb, <a href="http://github.com/foca/sinatra-mailer">http://github.com/foca/sinatra-mailer</a>),</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Sinatra::Mailer</span>.<span style="color:#9900CC;">config</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>:sendmail_path <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/usr/bin/fake-sendmail.sh&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#6666ff; font-weight:bold;">Sinatra::Mailer</span>.<span style="color:#9900CC;">delivery_method</span> = <span style="color:#ff3333; font-weight:bold;">:sendmail</span></pre></div></div>

<h3>2. Merb</h3>
<p>Edit your development configuration file (config/environments/development.rb)</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Merb::BootLoader</span>.<span style="color:#9900CC;">after_app_loads</span> <span style="color:#9966CC; font-weight:bold;">do</span>
    <span style="color:#6666ff; font-weight:bold;">Merb::Mailer</span>.<span style="color:#9900CC;">delivery_method</span> = <span style="color:#ff3333; font-weight:bold;">:sendmail</span>
    <span style="color:#6666ff; font-weight:bold;">Merb::Mailer</span>.<span style="color:#9900CC;">config</span> = <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#ff3333; font-weight:bold;">:sendmail_path</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/usr/bin/fake-sendmail.sh'</span> <span style="color:#006600; font-weight:bold;">&#125;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h3>3. Rails.</h3>
<p>Edit your development environment file with following options:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">action_mailer</span>.<span style="color:#9900CC;">delivery_method</span> = <span style="color:#ff3333; font-weight:bold;">:sendmail</span> 
config.<span style="color:#9900CC;">action_mailer</span>.<span style="color:#9900CC;">sendmail_settings</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>:location <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/usr/bin/fake-sendmail.sh&quot;</span><span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/05/03/how-to-test-mailers-in-sinatra-rails-and-merb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to deploy Sinatra / Merb applications with nginx</title>
		<link>http://blog.sosedoff.com/2009/07/04/how-to-deploy-sinatra-merb-applications-with-nginx/</link>
		<comments>http://blog.sosedoff.com/2009/07/04/how-to-deploy-sinatra-merb-applications-with-nginx/#comments</comments>
		<pubDate>Sat, 04 Jul 2009 15:59:47 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Nginx]]></category>
		<category><![CDATA[deploy]]></category>
		<category><![CDATA[merb]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=158</guid>
		<description><![CDATA[Developing with Merb or Sinatra ? Like web server nginx ? Ok, lets go.
Basically, Merb/Sinatra uses thin (based on eventmachine) server module, so it is working as stand-alone application. So, there is a way to connect nginx with these applications. Very simple &#8211; all you need to proxy requests to backend server. And all static [...]]]></description>
			<content:encoded><![CDATA[<p>Developing with <a href="http://merbivore.com/">Merb</a> or <a href="http://sinatrarb.com/">Sinatra</a> ? Like web server <a href="http://sysoev.ru/nginx">nginx</a> ? Ok, lets go.</p>
<p>Basically, Merb/Sinatra uses <a href="http://code.macournoyer.com/thin/">thin</a> (based on <a href="http://rubyeventmachine.com/">eventmachine</a>) server module, so it is working as stand-alone application. So, there is a way to connect nginx with these applications. Very simple &#8211; all you need to proxy requests to backend server. And all static files will be served by nginx.</p>
<pre>
upstream your_app {
  server 127.0.0.1:YOUR_PORT_NUMBER;
}

server {
  server_name YOUR_SERVERNAME;
  listen 80;
  charset utf-8;
  client_max_body_size 64M; # maximum of proxied filesize (for uploads)

  location / {
    root /path/to/app/root;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect false;
    if (-f $request_filename) {
      break;
    }

    if (!-f $request_filename) {
      proxy_pass http://your_app;
      break;
    }
  }

  # static content (images, flash, styles, etc.)
  location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|js|swf)$ {
    root /path/to/your/public/dir;
    access_log off;
  }
}
</pre>
<p>Then, all you need &#8211; start your application in daemon mode. Dont forget to bind application server to listen only on local address (127.0.0.1). </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/07/04/how-to-deploy-sinatra-merb-applications-with-nginx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

