I was able to successfully configure nginx and passenger phusion. I now have the following configuration

server {listen 80  server_name **sub1.example.com** root /home/user/app1/public }    
server {listen 80  server_name **sub2.example.com** root /home/user/app2/public }

Now, I want to change it to the following configuration

server {listen 80  server_name **dev.example.com/example1** root /home/user/app1/public }
server {listen 80  server_name **dev.example.com/example2** root /home/user/app1/public }

I tried using the location directive, but wasn't successful. I'm not even sure if this is possible. Any help would be greatly appreciated. Thanks.

The following are my nginx.conf settings

server {
   listen 80;
   server_name dev.example.com;

location = /app1/ {
   root /home/rails/app1/public/; 

   passenger_enabled on;
   rails_env development;
}
location /app2/ {
   root /home/rails/app2/public/; 
   passenger_enabled on;
   rails_env development;
}
}
link|improve this question
feedback

1 Answer

Previous Answer:

 server_name dev.example.com/example1 

is wrong. I am understanding you wanted dev.example.com to go to dev.example.com/example1. For such case, you need to do URL rewrite like below

location = / { rewrite ^ http://dev.example.com/example1 ; }

Answer after the comment:

From your comment i understood you wanted to serve multiple rails app from within same URI/domain.

server {
    listen 80;
    server_name dev.example.com;
    root /home/user/app1/public;
    passenger_enabled on;
    passenger_base_uri /app2;
    passenger_base_uri /app3;
    ....truncated...
    rails_spawn_method smart;
    rails_env production;
}
link|improve this answer
Kaji, what I want to do is instead of creating a sub-domain for every app I have, I would like to do something like this Have one super sub domain - dev.example.com and then redirect to the app's public folders when requests come. For example, dev.example.com/app1 - points to app1/public dev.example.com/app2 - points to app2/public dev.example.com/app3 - points to app3/public I have updated my question with my configuration. It might help you understand the problem better. – Naz Hussain Feb 6 at 9:58
I have updated the answer ...hope that solves for ya' – kaji Feb 6 at 10:43
feedback

Your Answer

 
or
required, but never shown

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