如何在子域上运行rails应用程序?

时间:2015-05-31 04:00:46

标签: ruby-on-rails ruby-on-rails-4

我想在一个域名上运行多个rails应用程序。

Ex:app1.expample.com和app2.example.com

现在我的根路线指向

body {
font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
font-size: 14px;
color: #333;
}

a:link,
a:visited {
    color: #000;
    text-decoration: none;
}

p {
    line-height: 14px;
}

/* General Layout */
div.container{
    max-width: 960px;
    margin: 0 auto;
    padding-left: 20px;
    padding-right: 20px;
}

article.post {
    border-bottom: 1px solid #bbbbbb;
}

article.post:last-of-type{
    border-bottom: none;
}

/* Header */
.site-header {
    border-bottom: 2px solid #999;
    padding-top: 10px;
}

/* Footer */
.site-footer {
    margin-top: 0px;
    border-top: 2px solid #999;
    margin-left: auto;
    margin-right: auto;
}

/* Navigation */
.site-nav {
    position: fixed;
    left:50%;
}

.site-nav ul{
    background-color: rgba(255,255,255,0.8);
    padding: 0px;
    margin: 0px;
}

.site-nav ul li{
    text-align: center;
    display: inline-block;
    overflow:hidden;
    text-decoration: none;
    margin-right: 10px;
    padding-right: 10px;
    border-right: 1px solid #DDD;
}

.site-nav ul li:last-of-type {
    border-right: none;
}

我如何将其更改为仅作为根在子域上运行?

1 个答案:

答案 0 :(得分:1)

由于您说“多个rails应用”,我假设您并不是指充当多个子域的多租户应用。

与DNS配置相比,这将更多地与DNS和Web服务器配置有关。您将需要在apache,nginx等中安装不同的应用程序作为虚拟主机配置。如果您使用Heroku,它将很容易,因为您只需要管理DNS。

我这样做是在nginx反向代理后面运行多个docker容器,它将虚拟主机路由到我的docker主机上不同端口提供的应用程序,但这将涉及更多设置。