My web application is hosted on AWS. It's your standard Laravel/PHP app. I would like to have a feature where users who register, have the ability to see their content in a dedicated subdomain (e.g. USERNAME.mywebapp.com)
obviously, modifying the NGINX config every time and restarting isn't going to cut it. I was wondering if AWS Route 53 offers the creation and removal of sub-domains using an API call that I can generate from my backend.
If anyone has an elegant suggestion on how I should attack this problem and aim at scalability — i'd be happy to hear.
Best Answer
You can definitely use the Route 53 API to create sub-domains, but you don't actually need to.
To support this you only need a
*.mywebapp.com
wildcard DNS record, as opposed to an explicit DNS record for every customer.With regard to managing your HTTP server config:
Firstly, I wouldn't be so quick to write off modifying your HTTP server configuration then running a config reload. It's quite practical to use something like Chef to automatically manage 100's of vhost configurations from a dynamically generated source (eg. a JSON file). I've used this approach personally and it isn't as bad as it sounds.
The other option is to have your application handle sub-domain routing. Here's a Laravel example: http://laravel-tricks.com/tricks/dynamic-subdomain-routing