简体   繁体   中英

How to I make a rails app run just on a subdomain?

I would like to run multiple rails apps on one domain name.

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

Right now I just have my root routes pointing to

root 'pages#home'
get "/" => "pages#home"

How would I change this to only run on a subdomain as the root?

Since you said "multiple rails apps" I am assuming you do not mean a multi-tenant app that acts as multiple subdomains.

This will have more to do with DNS and webserver configuration than app configuration. You will want to install the different apps as virtual host configurations in apache, nginx etc. If you are using Heroku it will be easy as you will only have to manage DNS.

I do this my running multiple docker containers behind an nginx reverse proxy which routes virtual hosts to apps serving from different ports on my docker host but that will involve a bit more setup.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM