How to programatically create a Meteor instance with a subdomain


#1

Hi everyone,

Do you know how https://reactioncommerce.com do to programmaticaly create a shop with their subdomain ?
I have an idea for an app that I’m building using Meteor and would like people to have their own instance easily.
Shopify also do the same thing but I never knew how this kind of stuff is done.

Thanks.


Guide Chapter: Multi-tenancy
#2

They will have a wildcard domain that routes all traffic to their servers and then whatever web server they are using will delegate the requests to either a single web server that knows how to handle the sub domains, or if they are running a multi-tenant platform, to the web server for that specific sub-domain.

To accomplish something similar in meteor, you could use nginx to route the requests to a particular meteor instance or have it rewrite the urls to a page structure and have your meteor router handle it from there, for example.
sub1.example.com -> example.com/sub1/


#3

I’d personally try to use Dokku here, which you can use to create new containers from a git repo with a Dockerfile. Dokku will automatically create the subdomains you want, and everything will be nicely separated. I’m not sure you can use Docker images which are already on the server to start a new app, but you can just open an issue and ask the authors if you’re interested. If that works, you can just use ShellJS to start a new app instance. Makes sense?


#4

Thanks for your answers.
Dokku seems really interesting, if I understand, it’s like a self hosted Heroku using docker containers right ?
I’m wondering if a simple solution in the future would be to use MDG Galaxy, something like : meteor deploy myapp.mysubdomain.com


#5

For those who are interested, here’s a post talking about the same thing : How do I deploy multiple meteor apps to the same digital ocean droplet using mupx & docker and using multiple domain names?