Nginx + Thin config on Windows for Rails app

Francis Daly francis at
Wed Aug 8 23:41:33 UTC 2012

On Wed, Aug 08, 2012 at 09:46:31PM +0200, Edward Stembler wrote:

Hi there,

> Now, I'm trying to add Nginx to the mix and I'm confused about how I
> should start Thin and how I should configure Nginx to forward to Thin.

If you have nginx listening on port 80, you should put Thin listening
on another port. It is probably best to put it listening on an address

> In my Nginx conf file do I specify the upstream servers as localhosts,
> or the machine's IP address? I'm not really sure what it's for.

The upstream is whatever Thin is listening on, and should include a specific
address, not (The "upstream" configuration does nothing until
it is referenced in the proxy_pass directive which follows.)

> upstream mywebapp_thin {
>   server;
> }
> server {
>     listen       80;
>     server_name  mywebserver www.mywebserver;
>     # locations et. al. excluded for brevity...

The important location{} block is the one that refers to all urls that
should be handled by Thin (and refers to no urls that should not be
handled by Thin).

In that location{}, you will want something like

  proxy_pass http://mywebapp_thin;

or maybe

  proxy_pass http://mywebapp_thin/;

Depending on how Thin responds, you may also want some proxy_set_header

Good luck with it,

Francis Daly        francis at

More information about the nginx mailing list