Nginx Sock And Rails Envinroment Error

Eric Wong normalperson at yhbt.net
Mon Feb 15 11:19:18 EST 2010


Alex Barlow <alexbarlowis at me.com> wrote:
> Hi
> 
> It goes
> 
> client <- TCP -> Unicorn                         => quiet errors (good)
> client <- TCP -> nginx <- TCP -> Unicorn         => quiet errors (good)
> client <- TCP -> nginx <- Unix socket-> Unicorn  => verbose errors (bad)
> 
> Strange i know!

Hi Alex,

My gut feeling is that somehow nginx is hitting a different instance of
your app when using the Unix socket.  Other than that, I'm confused.
More info/questions below.

> Ill try the socket in /tmp/ see what that does.
> 
> The Nginx error logs show nothing error wise really. My Nginx config is...
> 
> user  nginx;
> worker_processes  1;
> 
> events {
>     worker_connections  1024;
> }
> 
> http {
>     include       mime.types;
>     default_type  application/octet-stream;
> 
>     sendfile        on;
>     keepalive_timeout  65;
>     gzip  on;
> 
> 	upstream unicorn_sock {
> 		server unix:/root/pbr/unicorn.sock;
> 	}
> 	
>     server {
>         listen       80;
>         server_name  localhost;
> 		proxy_set_header Host $host;
> 
>         location / {
> 			proxy_pass  http://unicorn_sock;
>         }
>     }
> }

Nothing strange there, what's the verbosity of the nginx error_log?

Also, anything enlightening in the Rails production.log or Unicorn
stderr?

Which OS are you running?  Maybe there's a platform-specific bug
somewhere, too...

> This is currently throwing out verbose errors, in production (must be,
> its using asset host and the production database)
> 
> Put the sock in /tmp, no difference

Is there another Unicorn instance on the same box that it might be
somehow hitting?

What happens when you try have Unicorn listening on both TCP and a Unix
socket?  Just put both "listen" directives in your config file and point
nginx to the Unix socket.  Then try hitting the Unicorn TCP port
directly, and then also the Unix socket via nginx.

You can also try hitting the Unix socket directly by crafting your
own HTTP request using socat from th shell:

   req='GET / HTTP/1.1\r\nHost: example.com\r\n\r\n'
   printf "$req" | socat - UNIX:/root/pbr/unicorn.sock

P.S.: I might not have a chance to respond again for the next day
      or so due to personal matters.  Maybe somebody else on this
      list can help....

-- 
Eric Wong


More information about the mongrel-unicorn mailing list