sinatra is not working with passenger 2.2.0 on nginx?

134 views
Skip to first unread message

hui

unread,
Apr 17, 2009, 6:29:34 AM4/17/09
to Phusion Passenger Discussions
I am trying to run sinatra-rubygems (http://github.com/jnewland/
sinatra-rubygems/tree/master) on passenger 2.2.0, but all requests
returns 404 not found.

"rackup config.ru" (http://localhost:9292) is OK, and error.log for
nginx shows:
'127.0.0.1 - - [17/Apr/2009 16:45:41] "GET /Users/hui/Sites/sinatra-
rubygems/public " 404 18 0.0008'

it seems for sinatra all "@request.path_info" (==PATH_INFO?) is set to
"root", which in my case is "/Users/hui/Sites/sinatra-rubygems/
public", and leads to raising a 404 error.

my nginx config:

server {
listen 80;
server_name gems.local;
root /Users/hui/Sites/sinatra-rubygems/public;
passenger_enabled on;
}

config.ru for sinatra-rubygems

LIB_PATH = File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
$:.unshift LIB_PATH
require 'rack_rubygems'
use GemsAndRdocs, :urls => ['/cache', '/doc'], :root => Gem.dir
use Rack::Compress
run RackRubygems.new


anyone has some idea about this?
thx.

Tim Carey-Smith

unread,
Apr 18, 2009, 8:36:41 AM4/18/09
to Phusion Passenger Discussions
I found this problem too.
I wrote a dodgy Rack middleware which will "fix" the problem.

https://gist.github.com/e4337fdf7722a9e44e82

I'm going to try and track down the real cause now.

Ciao,
Tim

Tim Carey-Smith

unread,
Apr 18, 2009, 10:41:06 AM4/18/09
to phusion-...@googlegroups.com
I have traced the problem to before it gets to ruby.

These lines in the nginx content handler seem to be doing the wrong
thing, I think.

http://github.com/FooBarWidget/passenger/blob/master/ext/nginx/ContentHandler.c#L289
http://github.com/FooBarWidget/passenger/blob/master/ext/nginx/ContentHandler.c#L414-416

I am looking into how to convert the REQUEST_URI into the PATH_INFO
more correctly than my simple regex.

Ciao,
Tim

dylan

unread,
Apr 18, 2009, 1:08:53 PM4/18/09
to Phusion Passenger Discussions
I think this one is ok:

env["PATH_INFO"] = env["REQUEST_URI"].split('?', 2).first

from http://github.com/chneukirchen/rack/blob/663abfce9b71ab273c8adc0e76c233671bc43e1d/lib/rack/handler/scgi.rb#L30

On Apr 18, 10:41 pm, Tim Carey-Smith <g...@spork.in> wrote:
> I have traced the problem to before it gets to ruby.
>
> These lines in the nginx content handler seem to be doing the wrong  
> thing, I think.
>
> http://github.com/FooBarWidget/passenger/blob/master/ext/nginx/Conten...http://github.com/FooBarWidget/passenger/blob/master/ext/nginx/Conten...

Tim Carey-Smith

unread,
Apr 18, 2009, 7:27:13 PM4/18/09
to phusion-...@googlegroups.com
I have fixed the problem on my fork.

http://github.com/halorgium/passenger/commit/b8b360ea1d960e965fe7a7fec3df9a36aa04e13b
http://github.com/halorgium/passenger/commit/6d64144b1c57e5b7788537fe07dca1f3e9e7c388

Two commits cause I almost failed miserably :)

Can someone check that I'm not doing something insanely stupid?

Thanks Dylan for the split line.

Ciao,
Tim

Hongli Lai

unread,
Apr 19, 2009, 5:25:17 AM4/19/09
to phusion-...@googlegroups.com
On Sun, Apr 19, 2009 at 1:27 AM, Tim Carey-Smith <g...@spork.in> wrote:
>
> I have fixed the problem on my fork.
>
> http://github.com/halorgium/passenger/commit/b8b360ea1d960e965fe7a7fec3df9a36aa04e13b
> http://github.com/halorgium/passenger/commit/6d64144b1c57e5b7788537fe07dca1f3e9e7c388
>
> Two commits cause I almost failed miserably :)
>
> Can someone check that I'm not doing something insanely stupid?
>
> Thanks Dylan for the split line.

Thanks.

Can anybody confirm whether this change doesn't break Sinatra on Apache?

--
Phusion | The Computer Science Company

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Tim Carey-Smith

unread,
Apr 19, 2009, 6:20:08 AM4/19/09
to phusion-...@googlegroups.com
On 19/04/2009, at 9:25 PM, Hongli Lai wrote:

>
> On Sun, Apr 19, 2009 at 1:27 AM, Tim Carey-Smith <g...@spork.in> wrote:
>>
>> I have fixed the problem on my fork.
>>
>> http://github.com/halorgium/passenger/commit/b8b360ea1d960e965fe7a7fec3df9a36aa04e13b
>> http://github.com/halorgium/passenger/commit/6d64144b1c57e5b7788537fe07dca1f3e9e7c388
>>
>> Two commits cause I almost failed miserably :)
>>
>> Can someone check that I'm not doing something insanely stupid?
>>
>> Thanks Dylan for the split line.
>
> Thanks.
>
> Can anybody confirm whether this change doesn't break Sinatra on
> Apache?

The only thing which this changes is that it will overwrite the
PATH_INFO which apache provides.
Maybe it should change from:

> headers["PATH_INFO"] = headers["REQUEST_URI"].split("?", 2).first

to:

> headers["PATH_INFO"] ||= headers["REQUEST_URI"].split("?", 2).first

So it'll keep the existing value.

Ciao,
Tim

Eric Watson

unread,
Apr 22, 2009, 2:47:33 PM4/22/09
to Phusion Passenger Discussions
On Apr 19, 5:20 am, Tim Carey-Smith <g...@spork.in> wrote:
> On 19/04/2009, at 9:25 PM, Hongli Lai wrote:
>
>
>
>
>
> > On Sun, Apr 19, 2009 at 1:27 AM, Tim Carey-Smith <g...@spork.in> wrote:
>
> >> I have fixed the problem on my fork.
>
> >>http://github.com/halorgium/passenger/commit/b8b360ea1d960e965fe7a7fe...
> >>http://github.com/halorgium/passenger/commit/6d64144b1c57e5b7788537fe...
>
> >> Two commits cause I almost failed miserably :)
>
> >> Can someone check that I'm not doing something insanely stupid?
>
> >> Thanks Dylan for the split line.
>
> > Thanks.
>
> > Can anybody confirm whether this change doesn't break Sinatra on  
> > Apache?
>
> The only thing which this changes is that it will overwrite the  
> PATH_INFO which apache provides.
> Maybe it should change from:
>
> > headers["PATH_INFO"] = headers["REQUEST_URI"].split("?", 2).first
>
> to:
>
> > headers["PATH_INFO"] ||= headers["REQUEST_URI"].split("?", 2).first
>
> So it'll keep the existing value.
>
> Ciao,
> Tim

Thanks for tracking this down and fixing it, Tim. I had the same
problem.

Eric

gaiusparx

unread,
Apr 22, 2009, 7:00:47 PM4/22/09
to Phusion Passenger Discussions
Hi Tim Is your fork based on 2.2.1 or 2.2.0?

Hi Phusion, is this patch merged back to the git://github.com/FooBarWidget/passenger.git
already?

Thanks

On Apr 19, 7:27 am, Tim Carey-Smith <g...@spork.in> wrote:
> I have fixed the problem on my fork.
>
> http://github.com/halorgium/passenger/commit/b8b360ea1d960e965fe7a7fe...http://github.com/halorgium/passenger/commit/6d64144b1c57e5b7788537fe...
>
> Two commits cause I almost failed miserably :)
>
> Can someone check that I'm not doing something insanely stupid?
>
> Thanks Dylan for the split line.
>
> Ciao,
> Tim
>
> On 19/04/2009, at 5:08 AM, dylan wrote:
>
>
>
>
>
> > I think this one is ok:
>
> >   env["PATH_INFO"] = env["REQUEST_URI"].split('?', 2).first
>
> > fromhttp://github.com/chneukirchen/rack/blob/663abfce9b71ab273c8adc0e76c2...
>
> > On Apr 18, 10:41 pm, Tim Carey-Smith <g...@spork.in> wrote:
> >> I have traced the problem to before it gets to ruby.
>
> >> These lines in the nginx content handler seem to be doing the wrong
> >> thing, I think.
>
> >>http://github.com/FooBarWidget/passenger/blob/master/ext/nginx/Conten...

Tim Carey-Smith

unread,
Apr 22, 2009, 7:08:35 PM4/22/09
to phusion-...@googlegroups.com
On 23/04/2009, at 11:00 AM, gaiusparx wrote:

>
> Hi Tim Is your fork based on 2.2.1 or 2.2.0?

This is based off of 2.2.1.

Thanks,
Tim

Hongli Lai

unread,
Apr 23, 2009, 1:38:41 AM4/23/09
to phusion-...@googlegroups.com
On Thu, Apr 23, 2009 at 1:00 AM, gaiusparx <xen...@gmail.com> wrote:
>
> Hi Tim Is your fork based on 2.2.1 or 2.2.0?
>
> Hi Phusion, is this patch merged back to the git://github.com/FooBarWidget/passenger.git
> already?

Not yet, we haven't had the time to review it yet but it's on the top
of our todo list.

Hongli Lai

unread,
Apr 24, 2009, 12:48:57 PM4/24/09
to phusion-...@googlegroups.com
The problem has been fixed in git now.

Eric Watson

unread,
Apr 25, 2009, 10:41:39 AM4/25/09
to phusion-...@googlegroups.com


On Fri, Apr 24, 2009 at 11:48 AM, Hongli Lai <hon...@phusion.nl> wrote:

The problem has been fixed in git now.


Thanks, Hongli. I reinstalled passenger 2.2.1 from your github repo, rebuilt my arch linux package of nginx with the passenger module, and it works great.

Thanks again to Tim, too.

Eric
Reply all
Reply to author
Forward
0 new messages