Phusion Passenger + Nginx Virtual Host Configurati

2019-04-15 07:41发布

What my question is how do i map all the instances with port 80 with appropriate identical sub domains using Phusion Passenger + Nginx under Debian 6 for the following scenario.

Note : i am newbie to ruby on rails and server hosting , i unable to express my vision as question , please forgive me if i am wrong or correct me.

Hi , i am having an one product developed using ruby on rails , going to host in an dedicated server with 32 GB Ram and 8 Core Server Processor. Each client should have seperate DB and separate rails instance. I am replicating - duplicating code for each client with separate folders and giving different database names and so each serving as an different instance. Basically Source code is same for all client but only database name differs, so i am putting source code into different folders and staring as an separate rails application for each client.

For Example:

I am having one primary temp domain

www.product.com

For each client i need to have separate sub domain mapped to same server with same port(80) but with different rails instance name

www.client1.product.com
www.client2.product.com
www.clientn.product.com

As i know if i start rails instance , each will start at seperate port no's

client1 with start at port 3001
client2 with start at port 3002
client3 with start at port 3003

What my question is how do i map all the instances with port 80 with appropriate identical sub domains using Phusion Passenger + Nginx under Debian 6

if i access

www.client4.product.com , i need to get app running in port 3004

1条回答
相关推荐>>
2楼-- · 2019-04-15 07:52

I hope you found the solution by now, but for the sake of stackoverflow archive I'm going to provide an answer.

Generaly meaning you should use reverse proxy (http://wiki.nginx.org/RubyonRailsMongrel) with nginx, while your upstream will be a passenger|thin|unicorn|puma|mongrel (pick your favorite) server runnning your dedicated rails application (I will use duplicated code in order to isolate your client running environment.) You'll be able to provide load balancing with this method.

Now, you stipulate the use of Passenger, you could use a really simple setup if you compile nginx with passenger extention. (go to http://www.modrails.com/documentation/Users%20guide%20Nginx.html for better explanation)

server {
  listen 80;
  listen [::]:80 default_server ipv6only=on; # please for a better world be IPv6 compliant !
      server_name www.client1.product.com;
  root /my/rails/app1;
      passenger_enabled on;
}
server {
  listen 80;
  listen [::]:80 default_server ipv6only=on;
      server_name www.client2.product.com;
  root /my/rails/app2;
      passenger_enabled on;
}

.......

查看更多
登录 后发表回答