(使用phusion passenger + Nginx)以相同的端口(80)运行具有多个实例名称的相同rails应用程序 [英] (Using phusion passenger + Nginx) running same rails app with multiple instance names with same port (80)

查看:95
本文介绍了(使用phusion passenger + Nginx)以相同的端口(80)运行具有多个实例名称的相同rails应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

注意:我是Ruby和Rails的新手,无法将我的观点表达为问题,如果我错了或纠正我,请原谅我.

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.

您好,我正在开发一种使用Rails on Rails开发的产品,它将托管在具有32 GB Ram和8 Core Server Processor的专用服务器中.每个客户端应具有单独的数据库和单独的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. 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.

例如:

我有一个主临时域

www.product.com

对于每个客户端,我需要将单独的子域映射到具有相同端口的同一服务器(80) 但具有不同的Rails实例名称

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

据我所知,如果我启动rails实例,每个实例将从单独的端口号

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

我的问题是我如何将端口80的所有实例映射到适当的相同子域

如果我访问

www.client4.product.com,我需要使应用程序在端口3004上运行

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

更新:

在上述情况下,任何人都可以为乘机乘客+ Nginx发布步骤

Can anyone please post steps for phusion passenger + Nginx for the above scenario

推荐答案

以下是nginx + passenger的最小服务器块的示例示例

Here is a sample example of a minimal server block for nginx + passenger

server {
        listen 80;
        server_name client1.foobar.com;
        root /var/www/rails/client1/current/public;

    passenger_enabled on;
}

配置nginx的通常方法是创建一个子目录"sites-available",在该子目录中放置一个包含此代码段的名为"client1.foobar.com"的文件,然后在另一个名为"sites"的子目录中为此文件建立符号链接-启用".最后,将以下行添加到http块内的nginx.conf中

The usual way of configuring nginx is to make a subdirectory "sites-available" where you put a file named "client1.foobar.com" containing this snippet , then make a symbolic link for this file in another subdirectory named "sites-enabled". Finally you add the following line in you nginx.conf inside the http block

include /path/to/your/sites-enabled/*;

别忘了重新加载/重启您的nginx.

Do not forget to reload/restart your nginx.

通过使用符号链接的这种方式,您可以通过删除符号链接轻松地禁用所需的任何站点,而不会丢失配置文件.

This way of using symbolic link allows you to easily disable any site you want by deleting the symbolic link without losing your config file.

您可以在此处找到一些示例和更多文档: http://www. modrails.com/documentation/Users%20guide%20Nginx.html

You can find some example and more documentation here : http://www.modrails.com/documentation/Users%20guide%20Nginx.html

这篇关于(使用phusion passenger + Nginx)以相同的端口(80)运行具有多个实例名称的相同rails应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆