nginx dies after a few minutes (unicorn)

Igor Sysoev igor at sysoev.ru
Thu Aug 5 14:15:59 MSD 2010


On Thu, Aug 05, 2010 at 04:57:24AM +0200, Stanley Sh wrote:

> I am running unicorn behind nginx to host Rails 3
> 
> Both nginx and unicorn run flawlessly when first started but nginx dies
> inexplicably about 5-10 minutes later. Unicorn, however, stays up and is
> still accessible through its own port.

What do you mean by "dies" ?
Are you able to download any static file from nginx ?

> Here is my nginx configuration pertaining to this application:
> 
> 
> upstream unicorn {
>     server unix:/tmp/.sock fail_timeout=0;
> }
> 
> server {
>     server_name example.com;
>     root /www/example.com/current/public;
> 
>     keepalive_timeout 5;
> 
>     location / {
>         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>         proxy_set_header Host $host;
>         proxy_redirect off;
>         if (!-f $request_filename) {
>             proxy_pass http://unicorn;
>             break;
>         }
>     }
> }

By the way, it's better to use this configuration:

     location / {
         try_files  $uri  $uri/  @unicorn;
     }

     location @unicorn {
         proxy_pass http://unicorn;
         proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header Host $host;
         proxy_redirect off;
     }


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list