views:

37

answers:

1

I have one rails application needed to be deployed by passenger module nginx. This application needs to be served for hundred domain names. I don't have enough memory to launch hundred rails instances. I'm not sure the proper way to launch rails in few instances. It's the same application under different domain names.

server {
    listen 80;
    server_name www.a_domain.com;
    root /webapps/mycook/public;
    passenger_enabled on;
}
server {
    listen 80;
    server_name www.b_domain.com;
    root /webapps/mycook/public;
    passenger_enabled on;
} 
server {
    listen 80;
    server_name www.c_domain.com;
    root /webapps/mycook/public;
    passenger_enabled on;
}

As you can the above code, it would launch three rails instances. It would be nice to launch only instance to serve under these 3 domain. Anyone has some suggestions?

+1  A: 

Just set up multiple domain aliases for that server entry.

server {
    listen 80;
    server_name www.a_domain.com www.b_domain.com www.c_domain.com;
    root /webapps/mycook/public;
    passenger_enabled on;
}

That'll serve requests to each of those domains, and all hit the same app pool.

Chris Heald
+1 Setup multiple aliases and have your Rails app detecting which one should be executed inspecting the host variable.
Simone Carletti
Thanks for your comment.
Chamnap
We've done exactly what Simone suggests in exactly the way Chris describes, and it works fine.
pjmorse