index.html not working in public/content/ using passenger stand-alone

619 views
Skip to first unread message

Stephen Bannasch

unread,
May 16, 2011, 12:43:29 AM5/16/11
to phusion-...@googlegroups.com
I haven't been able to get passenger-standalone to serve an index.html file when accessing a directory in the public/ path for
my rails app.

I have passenger-stand-alone (v3.0.7) running a rails app and am starting it this way:

$ passenger start -a 127.0.0.1 -p 3003 -d

I have a directory inside the public directory which I would like when accessed to return the content of index.html if such a
file exists.

This file exists: public/content/index.html

However accessing this url: http://3003/content the server returns a Rails Routing Error

No route matches "/content" with {:method=>:get}

Is there any additional configuration options when running passenger-standalone that would enable this behavior?

Stephen Bannasch

unread,
May 16, 2011, 9:42:04 AM5/16/11
to phusion-...@googlegroups.com
The reasons this is a problem for me is that I have Apache passenger setup to use Ruby 1.9.2 but this specific Rails app needs
to be run under 1.8.7 -- an in addition I need to setup a second reverse proxy for couchdb in the apache vhost configuration.

I was following the setup described here:

http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/

And had the problem that I am not able to serve index.html content from path ending in a dir reference.

I described the simplified problem in the earlier post.

Everything is working with the apache vhost using a reverse proxy to the passenger stand-alone instance running in 1.8.7
*except* for the delivery of index.html

I tried making this change in passenger to tell nginx to resolve a directory access to index.html (if one exists):

index 93cbaad..0b27f92 100644
--- a/lib/phusion_passenger/templates/standalone/config.erb
+++ b/lib/phusion_passenger/templates/standalone/config.erb
@@ -82,6 +82,7 @@ http {
listen <%= nginx_listen_address(app) %>;
server_name <%= app[:server_names].join(' ') %>;
root '<%= app[:root] %>/public';
+ index index.html;
passenger_enabled on;
rails_env <%= app[:env] %>;
passenger_spawn_method <%= app[:spawn_method] %>;

After starting passenger in stand-alone mode I see that change in the config file in the config file located here:
/tmp/passenger-standalone.<nnnnn>/config

Loading the full url (a SproutCore app) works:

http://127.0.0.1:3003/sc-runtime/index.html

While loading the partial url fails with a routing error from rails:

http://127.0.0.1:3003/sc-runtime/

=> No route matches "/sc-runtime/" with {:method=>:get}:

Stephen Bannasch

unread,
May 16, 2011, 10:37:04 AM5/16/11
to phusion-...@googlegroups.com
The problem might be here in the nginx ContentHandler:

https://github.com/FooBarWidget/passenger/blob/master/ext/nginx/ContentHandler.c#L147

This code appears to only check for the presence of index.html in the root of the public dir.

The similar code in the apache2 extension appears to check any file where the fileType == FT_DIRECTORY and if the url ends with
'/' athen checks to see if path + index.html exists.

https://github.com/FooBarWidget/passenger/blob/master/ext/apache2/Hooks.cpp#L461

Stephen Bannasch

unread,
May 16, 2011, 11:32:45 AM5/16/11
to phusion-...@googlegroups.com
I've fixed this and created a pull request:

https://github.com/FooBarWidget/passenger/pull/15

I'm not much of a C programmer so only did the bare minimum to get this working.

I generated the gem, installed it into 1.8.7, deleted the ~/.passenger dir (where the stand-alone build artifacts are located)
and re-created and started the stand-alone server:

$ passenger start -a 127.0.0.1 -p 3003

Now accessing this url renders the SproutCore application

http://127.0.0.1:3003/sc-runtime/

The rest of the rails app also works.

Stephen Bannasch

unread,
May 20, 2011, 2:45:07 PM5/20/11
to phusion-...@googlegroups.com

Hongli,

Are you interested in this pull request.

I have team members that I'd like to use this feature and it would be nice if they didn't have to clone the repo, and buildand install the gem manually.

Reply all
Reply to author
Forward
0 new messages