0

I'm having trouble serving a rails app at a sub uri using passenger and rails.

The relevant part of my nginx.conf is as follows:

server {
    listen 80;
    server_name ~^(.*)\.domain\.com$ ;

    location /redmine/ {
        root /home/www/data/$1/redmine/public;
        passenger_enabled on;
        passenger_base_uri /redmine;
    }
}

Nginx is actually looking for a static file at /home/www/data/pckprojects/redmine/public/redmine/index.html .

Any thoughts? Thanks.

Update:

The passenger documentation for this is pretty clear, so I should have noted why I'm trying to go about it a different way.

Ultimately I would like / to be serving a Django application, probably via fastcgi. The passenger documentation for deploying at a sub uri is for if you are serving static content at / and want your rails app and at a sub uri. Since I'm going to serve a fastcgi application, using a symlink to link to the rails application isn't going to work.

2 Answers 2

0

Try "alias" instead of "root".

location /redmine/ {
  alias /home/www/data/$1/redmine/public;
1
  • I also made some other changes, but this seemed to be key. I'm going to test some more, then post my complete solution up top. Thanks!
    – philipk
    Jul 18, 2010 at 23:09
0

I'll assume that your redmine installation lives at /home/www/data/$subdomain/redmine/.

Following passanger's nginx deployment guide, it looks like if you want to serve a rails app from /sub_uri sub_uri folder should be a symlink to your app's public folder - ex. /redmine -> /path/to/redmine/public. Since you put your redmine installation into redmine folder in your (future) root directory and want to serve it from /redmine I would suggest renaming it - for the purposes of this post I'll assume you renamed it to foo.

There are couple of adjustments you have to make. First off all you have to change root directory of your virtual server:

server {
    listen 80;
    server_name ~^(.*)\.domain\.com$ ;
    root /home/www/data/$1/;
    passenger_enabled on;
}

Next thing, we need to create aforementioned symlink:

# cd /home/www/data/$1
# ls
foo
# ln -sf foo/public redmine
# rm foo/public/index.html

I haven't installed redmine before, but if there's index.html in its public folder you should remove it as per above line - instead of serving that static file nginx now should serve your app.

And the final step is to tell nginx that we want redmine running under /redmine so we end up with following in your nginx.conf:

server {
    listen 80;
    server_name ~^(.*)\.domain\.com$ ;
    root /home/www/data/$1/;
    passenger_enabled on;
    passenger_base_uri /redmine;
}
1
  • Sorry, I have read the documentation, but should have specified why I'm trying to go about it differently. I'll update my question.
    – philipk
    Jul 18, 2010 at 19:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .