Take the 2-minute tour ×

I'm using nginx/1.2.1 + Phusion Passenger 3.0.13 and I'm setting up multiple Rails apps on a single server using the passenger_base_uri param in my nginx.conf file. It looks something like the following:

server {
    listen       80;
    server_name  localhost;
    root /path/to/code;
    passenger_enabled on;
    passenger_base_uri /app1;
    passenger_base_uri /app2;
    rails_env production;

Now let's say I'm hosting this on www.mysite.com. My problem is that when I go to www.mysite.com/app1, it loads just fine... but all the links from that page point to www.mysite.com. The app has no idea that it's actually behing hosted at a subfolder called app1.

I know I can manually type add the following config option to my app:

config.action_controller.relative_url_root = "/app1"

But I was hoping to not have to manually add that. Any ideas on how to programmatically get that information in to the Rails app so I can access it as a variable and update my links correctly?


share|improve this question
I would use subdomains instead of separate paths to solve this. –  Gabe Kopley Sep 20 '12 at 22:07
Let's assume I can't/don't want to use subdomains in this particular setup. Any ideas? –  fffanatics Sep 20 '12 at 23:34
This is a bit old, but I'm wondering the same thing. We use separate paths to spin up adhoc test servers with nginx and I'm running into the same issue with links. –  bigtunacan Dec 4 '13 at 1:43
add comment


Your Answer



Browse other questions tagged or ask your own question.