[英]Phusion Passenger + Nginx Virtual Host Configuration for Ruby on Rails Application in Debian 6
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. 我的问题是,在以下情况下,如何使用Debian 6下的Phusion Passenger + Nginx将具有端口80的所有实例映射到适当的相同子域。
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. 注意:我是Ruby和Rails服务器托管上的新手,我无法将我的观点表达为问题,如果我错了或纠正我,请原谅我。
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. 嗨,我正在使用Rails开发一款产品,它将托管在具有32 GB Ram和8 Core Server Processor的专用服务器中。 Each client should have seperate DB and separate rails instance.
每个客户端应具有单独的数据库和单独的rails实例。 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.
基本上,所有客户端的源代码都是相同的,但是只有数据库名称不同,所以我将源代码放入不同的文件夹中,并为每个客户端盯着一个单独的rails应用程序。
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 对于每个客户端,我需要将单独的子域映射到具有相同端口(80)但具有不同Rails实例名称的同一服务器
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 据我所知,如果我启动rails实例,每个将在单独的端口号开始
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 我的问题是我如何使用Debian 6下的Phusion Passenger + Nginx将具有端口80的所有实例映射到适当的相同子域
if i access 如果我访问
www.client4.product.com
, i need to get app running in port 3004 www.client4.product.com
,我需要使应用程序在端口3004中运行
I hope you found the solution by now, but for the sake of stackoverflow archive I'm going to provide an answer. 我希望您现在就找到了解决方案,但是为了提供stackoverflow存档,我将提供一个答案。
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. 一般而言,您应该将反向代理( http://wiki.nginx.org/RubyonRailsMongrel )与nginx一起使用,而上游将是运行专用rails应用程序的乘客|瘦身|独角兽|美洲狮|杂种(选择您喜欢的服务器)(我将使用重复的代码来隔离您的客户端运行环境。)您将可以使用此方法提供负载平衡。
Now, you stipulate the use of Passenger, you could use a really simple setup if you compile nginx with passenger extention. 现在,您规定了“乘客”的使用,如果您通过乘客扩展编译nginx,则可以使用一个非常简单的设置。 (go to http://www.modrails.com/documentation/Users%20guide%20Nginx.html for better explanation)
(转到http://www.modrails.com/documentation/Users%20guide%20Nginx.html以获得更好的解释)
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;
}
....... .......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.