<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Brainspl.at: New Nginx Conf with Rails Caching</title>
    <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Brainspl.at</description>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Dan Kubb</title>
      <description>&lt;p&gt;Ezra, do you know if its possible to further refine the Nginx config file so that it only does "-f $request_filename" if the request is a GET or HEAD request?&lt;/p&gt;

&lt;p&gt;The idea would be to use page caching for GET/HEAD requests provided the file exists.  If the file didn't exist OR the request was POST, PUT, DELETE, etc Nginx would proxy the request to Mongrel.&lt;/p&gt;</description>
      <pubDate>Thu, 05 Apr 2007 06:09:14 +0000</pubDate>
      <guid>urn:uuid:89a66a66-a70a-446d-8fd9-8387c41c0e13</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-4084</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by wireless</title>
      <description>For Capistrano's disable_web command you need add extra configuration 

&lt;pre&gt;
location /system/maintenance.html {
}
&lt;/pre&gt;

after  

&lt;pre&gt;
if (-f /var/www/example.com/shared/system/maintenance.html){
          rewrite  ^(.*)$  /system/maintenance.html last;
          break;
}
&lt;/pre&gt;</description>
      <pubDate>Thu, 21 Dec 2006 22:58:13 +0000</pubDate>
      <guid>urn:uuid:869efaf6-48f6-499a-bf90-876192e13aee</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3839</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Tom Fakes</title>
      <description>I recently updated my action_cache plugin to support the x-accel-redirect header in nginx.  Its pretty sweet!

Check it out here:
http://blog.craz8.com/articles/2006/11/13/rails-action_cache-now-supports-nginx-and-x-accel-redirect

The key point is that you get almost the speed of page caching, but you can do things like access control in before_filters.
</description>
      <pubDate>Thu, 23 Nov 2006 01:35:30 +0000</pubDate>
      <guid>urn:uuid:6f352446-5a1c-4dfc-9304-0f7ab5b98f00</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3777</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Kyle</title>
      <description>Hey thanks for this info. This seems like it is very production worthy and I plan on trying it out on my VPS soon. I will definitely use it in production if I can get SSL to work on it and everything else goes well.
I found a great article on how to do different things with the conf file here: http://zh.stikipad.com/notes/show/nginx</description>
      <pubDate>Tue, 14 Nov 2006 20:19:00 +0000</pubDate>
      <guid>urn:uuid:eb96ac6b-e89f-4826-b9ce-f4f832ae29bf</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3766</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Ezra</title>
      <description>Thanks Dan, It's fixed now. Yeah nginx has really proven itself to be completely rock solid, fast as hell and a complete lightweight wen it comes to resource consumption. nginx++</description>
      <pubDate>Sat, 11 Nov 2006 07:31:26 +0000</pubDate>
      <guid>urn:uuid:3e5a464f-8dfc-47e3-b7c7-8423d55cf8ff</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3757</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Dan Kubb</title>
      <description>&lt;p&gt;Ezra, there's a small bug in the log_format part of your config file.  There needs to be a dollar sign ($) in front of the word "http_x_forwarded_for" for it to be merged into the logs.&lt;/p&gt;

&lt;p&gt;Thanks for spreading the word about Nginx!  I've just started testing it and its blazingly fast.  Its also probably the easiest web server (next to Mongrel) that I've ever set up.&lt;/p&gt;</description>
      <pubDate>Fri, 10 Nov 2006 01:00:22 +0000</pubDate>
      <guid>urn:uuid:ab0880a8-f832-4f3c-8d70-31d721901c03</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3756</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Yan</title>
      <description>Has anyone had experience with a non standard public caching path? In my rails app I'm caching to public/cache so that sweeping is easier. I tried adding a rewrite rule to nginx to compensate for this, after the standard html rewrite rule:


if (-f $document_root/cache/$request_filename.html) {
   rewrite (.*) /cache/$1.html; break;
}

Doesn't seem to be working. I'm still playing with it though...
</description>
      <pubDate>Mon, 09 Oct 2006 16:29:24 +0000</pubDate>
      <guid>urn:uuid:d31053fd-6259-4ca2-a45a-00449c9a47d0</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3713</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by ed</title>
      <description>al and ezra,
thanks for info.  have either of you had timout problems uploading large files?  if so, is it the client_body_timeout setting that fixes it?  seems logical...

im getting timouts when uploading even medium sized files (5MB):

error] 6155#0: *62 upstream timed out (110: Connection timed out) while sending request to upstream, client: 24.124.123.211, server: edhickey.com, URL: "/tracks/create?list_id=3&amp;amp;upload_id=1159411079", upstream: "http://127.0.0.1:11000/tracks/create?list_id=3&amp;amp;upload_id=1159411079", host: "edhickey.com:4000", referrer: "http://edhickey.com:4000/tracks/new?list_id=3"
</description>
      <pubDate>Sat, 30 Sep 2006 23:16:40 +0000</pubDate>
      <guid>urn:uuid:b726e4bd-57cf-4e78-a8dc-8f5e495122dc</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3704</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Labrat</title>
      <description>Sorry I figured it out (needed to kill nginx and restart).

It's really great.  the only problem is that I can't get file uploading via acts_as_attachment to work in production...</description>
      <pubDate>Fri, 29 Sep 2006 05:42:01 +0000</pubDate>
      <guid>urn:uuid:5ba0356b-d585-4c5d-b7f6-0416152da426</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3699</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Ezra</title>
      <description>I have added the client_max_body_size to the linked config file. It turns out you have to put it inside the server block with a rails config.</description>
      <pubDate>Fri, 29 Sep 2006 05:18:13 +0000</pubDate>
      <guid>urn:uuid:a906a9ca-c650-4e04-94eb-a701d8d4f6c8</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3698</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Labrat</title>
      <description>I can't get mongrel + apache to play nice with send_file/acts_as_attachment so I tried switching to nginx in this post.

Unfortunately, I can't get past the "Welcome to nginx!" page.  Can't figure out what I'm doing wrong...</description>
      <pubDate>Thu, 28 Sep 2006 10:17:30 +0000</pubDate>
      <guid>urn:uuid:7a9d2edc-a067-42b4-bbef-4d9dc6533c85</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3697</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by al</title>
      <description>I'am not davy but you can add this directive in the following context:
&lt;br/&gt;
&lt;b&gt;http, server, location&lt;/b&gt;
&lt;br/&gt;
More here:
http://wiki.codemongers.com/NginxHttpCoreModule#client_max_body_size
&lt;br/&gt;
There is know a wiki for the english docs ;-) http://wiki.codemongers.com/
&lt;br/&gt;
Hth</description>
      <pubDate>Wed, 27 Sep 2006 19:42:53 +0000</pubDate>
      <guid>urn:uuid:250ff9ef-33c8-46f2-95b0-8fd59b838505</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3696</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by ed</title>
      <description>Davy,
where did you put that line, exactly?

thanks</description>
      <pubDate>Thu, 21 Sep 2006 02:50:19 +0000</pubDate>
      <guid>urn:uuid:81ecee72-b5ad-4736-bf27-818c440c81de</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3678</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Davy</title>
      <description>ed:

I was able to change the client_max_body_size to 10m and successfully upload a file larger than 1 meg.  </description>
      <pubDate>Wed, 20 Sep 2006 21:39:57 +0000</pubDate>
      <guid>urn:uuid:c6b2baa6-9b93-483f-b1f8-dd93cc78cbe4</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3677</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by ed</title>
      <description>anyone get file uploading to work?  i can upload small (&lt;1MB) files without issue, but not larger ones (5MB, etc). im using the above conf file (nginx configured without ssl though) and discovered  the client_max_body_size config var which i set to 1024g, but still i get upstream timeout errors:

2006/09/16 01:04:29 [warn] 3376#0: *64 a client request body is buffered to a temporary file /usr/local/nginx/client_body_temp/00000000001, client: 24.124.123.211, server: serverside.com, URL: "/tracks/create?track_counter=1&amp;upload_id=1158389209048", upstream: "http://127.0.0.1:11000", host: "thedomain.com:4000", referrer: "http://thedomain.com:4000/tracks/new?list_id=3"

2006/09/16 01:08:11 [error] 3376#0: *64 upstream timed out (110: Connection timed out) while sending request to upstream, client: 24.124.123.211, server: serverside.com, URL: "/tracks/create?track_counter=1&amp;upload_id=1158389209048", upstream: "http://127.0.0.1:11007/tracks/create?track_counter=1&amp;upload_id=1158389209048", host: "thedomain.com:4000", referrer: "http://thedomain.com:4000/tracks/new?list_id=3"

this last timeout error keeps showing up and the file never completes uploading

thoughts?</description>
      <pubDate>Sat, 16 Sep 2006 07:17:43 +0000</pubDate>
      <guid>urn:uuid:95699097-681b-479e-8cc5-06c4cc7f84fb</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3671</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Al</title>
      <description>Ezra: I have missreaded the source, the 'proxy_pass_header' is only from backend to client.</description>
      <pubDate>Thu, 14 Sep 2006 08:52:10 +0000</pubDate>
      <guid>urn:uuid:28d368be-4752-48bc-8823-a0a3dd1a8f01</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3667</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Al</title>
      <description>Ezra: have you tried the 'proxy_pass_header Host;' instead of 'proxy_set_header Host $http_host;'.

The main difference is, as far as i have seen in the source, that with _pass nginx don't create a $ARRAY internal.

Regards

Aleks</description>
      <pubDate>Thu, 14 Sep 2006 07:50:10 +0000</pubDate>
      <guid>urn:uuid:1b75810d-6857-4a64-8902-41d77c9da127</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3666</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Kevin Marsh</title>
      <description>Ezra: Odd, did a quick 'mental-diff' between yours and mine and couldn't find any discrepancies. For the heck of it I thought I'd wipe out mine and start fresh from yours--works like a charm! Thanks!</description>
      <pubDate>Wed, 13 Sep 2006 22:35:37 +0000</pubDate>
      <guid>urn:uuid:6345c18f-982d-4d3c-a786-7e3db3ba7b77</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3659</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Ezra</title>
      <description>Kevin- Check out the config file again. I updated it to forward the correct headers to mongrel so account_location works fine.</description>
      <pubDate>Wed, 13 Sep 2006 20:08:06 +0000</pubDate>
      <guid>urn:uuid:904e0ab9-1085-4239-90fa-d457278d7a96</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3658</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Kevin Marsh</title>
      <description>I too, jumped on the nginx bandwagon and have found it pretty pleasant thus far.

rick: I'm having the same issue, only with subdomains. DHH's Account Location plugin uses request.subdomains, which don't get passed to Rails by nginx. Making the upstream cluster the same is impossible, because the magic happens with a wildcard DNS entry (*.example.com). I'm looking for a solution for this.

And, to make Capistrano's disable_web command happy, add this to your conf, before all the other 'location' directives:

&lt;pre&gt;
         if (-f /var/www/example.com/shared/system/maintenance.html){
          rewrite  ^(.*)$  /system/maintenance.html last;
          break;
        }
&lt;/pre&gt;</description>
      <pubDate>Wed, 13 Sep 2006 19:24:40 +0000</pubDate>
      <guid>urn:uuid:23d81d49-b80c-4383-ae63-0ffbe0180107</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3656</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by rick</title>
      <description>Great stuff, Ezra.  I managed to get this 95% working on my custom mephisto setup too.  I'll post the config once it's 100%.

One odd thing I noticed, it uses the name of the "pack of mongrels" (upstream cluster) as the request.host in rails.  For instance, if you were to use home_url using that config, you'd get http://mongrel/.  Is there a way to pass the true domain on?  

For now I'm either using absolute paths without the host name (home_path route), or setting the domain name as the name of the upstream cluster.</description>
      <pubDate>Wed, 13 Sep 2006 13:31:45 +0000</pubDate>
      <guid>urn:uuid:27e4e73d-e93b-4b39-ac70-6d92ab7d7d52</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3654</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Al</title>
      <description>There is a *undocumented* header field 'X-Accel-Redirect' which looks similar.

The main difference is:

1.) set an URI, but not a path

2.) it must be set as internal for nginx:

---
location /protected/ {                                                                                                                  
internal;
root /some/path;
}
---

Regards

Aleks</description>
      <pubDate>Wed, 13 Sep 2006 08:02:29 +0000</pubDate>
      <guid>urn:uuid:42ff23cf-bb66-48a7-8467-8fb7047cc8bc</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3653</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Ezra</title>
      <description>Yeah nginx supports virtual hosts and all the stuff you expect from a webserver. Curiously the only thing notably absent is a plain old cgi interface. I will post anopther config with some vhosts defined in it. Basically if you look at the linked config, the server {} block is one vhost. So you make another server block for each vhost and change the domain it looks for. Like this: &lt;br /&gt;
&lt;pre&gt;
    server {
        listen       80;
        server_name   example.com  www.example.com;
        root /Users/ez/nginx/public;
        # the rest of the config.
     }
&lt;/pre&gt;        </description>
      <pubDate>Wed, 13 Sep 2006 01:53:05 +0000</pubDate>
      <guid>urn:uuid:5d043f54-1e24-4aca-b9af-64c9f7675869</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3652</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Davy</title>
      <description>Nevermind on that last question!  I just installed it and the vhost part in the config.</description>
      <pubDate>Wed, 13 Sep 2006 01:50:42 +0000</pubDate>
      <guid>urn:uuid:bbdac1c3-f76f-403e-9910-349fcf1f4c2f</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3651</link>
    </item>
    <item>
      <title>"New Nginx Conf with Rails Caching" by Davy</title>
      <description>Ezra, first off thanks for all the useful information that you blog about!  I'm excited to try out nginx even though my site is pretty low traffic.  One quick question though, does nginx support any type of virtual hosts?  What are the options for serving up multiple rails sites on one machine with nginx?</description>
      <pubDate>Wed, 13 Sep 2006 01:20:52 +0000</pubDate>
      <guid>urn:uuid:9c1567b1-2943-4626-8f51-50f020141731</guid>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching#comment-3650</link>
    </item>
    <item>
      <title>New Nginx Conf with Rails Caching</title>
      <description>&lt;p&gt;[UPDATE] The config file has been updated and commented so it is easier to figure out. It also sets the right header when it proxies to mongrel and doesn;t choke on the foo.js?394732323 urls that rails generated for static assets.&lt;/p&gt;


	&lt;p&gt;OK this is very sweet. We have a new Nginx conf file that works perfectly with rails page caching. nginx serves all static files and all rails cached file. &lt;b&gt;Fast&lt;/b&gt;
&lt;br /&gt;&lt;br /&gt;
I want to thank &lt;a href='http://blog.kovyrin.net/'&gt;Alexy Kovyrin&lt;/a&gt; and &lt;a href='http://imajes.info'&gt;James Cox&lt;/a&gt; for their help in getting this config perfected. This makes nginx truly one of the best options for fronting a cluster of mongrels.
&lt;br /&gt;&lt;br /&gt;
Might as well get the latest version while we&amp;#8217;re at it.
&lt;pre&gt;
curl -O http://sysoev.ru/nginx/nginx-0.4.0.tar.gz
tar -xvzf nginx-0.4.0.tar.gz
cd nginx-0.4.0
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
make
sudo make install
&lt;/pre&gt;
&lt;br /&gt;
Now for the new config file. Here you go folks, get it while its hot!&lt;br /&gt;&lt;br /&gt;
&lt;a href='/nginx.conf.txt'&gt;nginx.conf&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Tue, 12 Sep 2006 16:02:00 +0000</pubDate>
      <guid>urn:uuid:d50686e3-d16b-421b-9f74-7320a0880073</guid>
      <author>ezmobius</author>
      <link>http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching</link>
      <category>nginx</category>
      <category>proxy</category>
      <category>loadbalance</category>
      <category>server</category>
      <category>deployment</category>
      <trackback:ping>http://brainspl.at/articles/trackback/3645</trackback:ping>
    </item>
  </channel>
</rss>
