I am creating a SaaS project that lets end-users run and access a dashboard as a web app which is a Docker container, which means every user has his own dashboard which is a running docker container, and I would like them to access their servers/containers using my domain (HTTP) as follow: user1: subdomain.mydomain.com/user1app, user2: subdomain.mydomain.com/user1app, etc.
Currently, I am using LocalTunnel however it is not stable and requires me to use 1 subdomain for every user, for example: user1.mydomain.com, user2.mydomain.com, etc.
but what if we scale and get more users? I need a dynamic and automatic way to create users custom URL link to expose their running docker containers and give them access such as, subdomain.mydomain.com/user123, subdomain.mydomain.com/user456, etc.
I tried to use ngrok, however, it is limited in many ways e.g. 40-requests/minute limit, and not free.
Thanks
2
Answers
I recommend running an nginx-revsere-proxy with docker and the you can host as many webapp as you want only with one single ip.
https://github.com/nginx-proxy/nginx-proxy
There you can add per host configs or even change the default configuration. So you can write for each dashboard a config or use variables and a bashscript to create the host configs
If you have multiple docker containers running locally, you can expose them to the internet using ngrok.
First, install ngrok:
$ npm install -g ngrok
Then, start ngrok and specify the port that your docker container is running on:
$ ngrok http 80
Ngrok will give you a URL that you can use to access your docker container from the internet.