Reputation: 511
I am working on a Ruby On Rails app, it has multiple sub-domains for example: "admin.example.com", "user.example.com", "members.example.com" , so my question is how to deploy my app so that all these sub-domains work in staging mode in heroku. It is working fine on local host (using lvh.me to access subdomains). Right now I am not using any custom domain , I am using default domain name provided by Heroku.
Upvotes: 3
Views: 3777
Reputation: 1554
Heroku has a free add-on that you can use to enable custom domain (and subdomain) names on their platform.
https://devcenter.heroku.com/articles/custom-domains
If you read that support article, you'll see that you need to follow these steps:
Verify your account on Heroku by adding a credit card number - they won't charge anything for this particular add-on.
Run this command at your command line to add the domain name example1.com to your account, so Heroku knows to route inbound traffic using that domain to your app:
$ heroku domains:add example1.com
Run this command to route all sub-domains of example1.com to your app:
$ heroku domains:add *.example1.com
The tricky part may be configuring your domain name to route traffic to Heroku in the first place. You'd do that by going to your domain name registrar, and creating a CNAME record in your DNS setup to route all traffic on *.example1.com to the original URL for your app on Heroku - example1.herokuapp.com.
Upvotes: 2