0

I am developing an application (please see image) where users can register. When a user registers, then a service is created inside a docker for this user. The service must be reached under a subdomain also created for this user (user1.example.com) and a fixed port xyz (the port is always the same). All this must happen without restarting the server.

  • How can I do this?
  • Does anyone know of a guide where I can read about this?
  • Is my approach ok?

My main application 1 (where users first register) is done with django. I was thinking of doing this using nginx and docker.

Thank you very much.

what i want to do

fbzyx
  • 189
  • 1
  • 16
  • 1
    Maybe have a look at [this](https://stackoverflow.com/questions/9578628/redirecting-a-subdomain-with-a-regular-expression-in-nginx). – super Jul 14 '21 at 21:19
  • I can think of several ways to achieve it. You could write a script that periodically (or triggered by every account creation) checks a specific endpoint in your service to retrieve all accounts, and then generate appropiate vhosts config file for nginx, then do nginx -r to load it. Another way would be using openresty, to do a similar thing, but from inside nginx itself, written in LUA. I like more this second approach, but probably requires more time to develop. Of course, if the amount of accounts you expect is very high, you'd need to evaluate the scalability of the solution chosen. – Cristian Jul 14 '21 at 21:20
  • What @super mentioned seems much simpler than my solutions. You could rewrite all the requests to the same service, but send the subdomain as a param or header. I like it! – Cristian Jul 14 '21 at 21:25

0 Answers0