Trevor
Trevor

Reputation: 43

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?

Upvotes: 0

Views: 640

Answers (1)

errata
errata

Reputation: 26812

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.

Upvotes: 1

Related Questions