Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

Try "alias" instead of "root".

location /redmine/ {
  alias /home/www/data/$1/redmine/public;
share|improve this answer
    
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 '10 at 23:09

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;
}
share|improve this answer
    
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 '10 at 19:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.