Fixed it!
Rails was considering all requests to be local. As the request was coming from
the local ip (from nginx i assume)
i put these headers in nginx
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
Works fine now
Alex
On 15 Feb 2010, at 16:19, Eric Wong wrote:
> Alex Barlow <[email protected]> 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
_______________________________________________
Unicorn mailing list - [email protected]
http://rubyforge.org/mailman/listinfo/mongrel-unicorn
Do not quote signatures (like this one) or top post when replying