I want to run the same Rails 3 app at urls: davinci.local.dev:8081 davinci.testing.dev:8082 and with environments development and testing, respectively.
I am using Nginx and passenger. My first attempt was:
server {
listen 8081;
server_name .davinci.local.dev;
root /Users/Nerian/NetBeansProjects/DaVinci/DaVinci/public;
passenger_enabled on;
rails_env development;
#rails_env development
}
server {
listen 8082;
server_name .davinci.testing.dev;
root /Users/Nerian/NetBeansProjects/DaVinci/DaVinci/public;
passenger_enabled on;
rails_env test;
#rails_env development
}
Yet when I browse to said urls, I get to the same deployment. If I first request the testing one, then it is that the app that is served always, whether I browse to davinci.local.dev or davinci.testing.dev. If I first request the development one, then it is that one which is served always.
Both deployments are using the same root app. Is there a way to make this works?
The objective is to serve the same app at different ENV in different domains.
I had a similar problem. I wanted a Rails application (named apparat) to have two nginx instances: example.eu for english version of the site and example.ee for estonian version. They share exactly the same functionality, so it makes sense to have just one code base for it (but I do have to make sure static assets like user-uploaded images won’t collide).
However, similar to above, if I accessed example.ee, I got the example.eu instance of my Rails app. Possibly some quirk in nginx / passenger?
Anyway I got around by making an arbitrary symlink to /home/apparat, for instance
and changed the nginx config respectively
So I’m able to trick nginx into thinking these are different directories.