I’m having an SaaS developed where users will get a subdomain and would
like to set this up as efficiently as possible. As of now i’m using
apache but would like to move to nginx and get this setup
I’m having an SaaS developed where users will get a subdomain and would
like to set this up as efficiently as possible. As of now i’m using
apache but would like to move to nginx and get this setup
Well, the idea is to set your root dynamically from the default
server block depending on the ‘host’ header.
You can either use $http_host as a part of your root, which
is probably not a good thing, or map it to some subdir, and
use its value instead:
In your example does that mean I would need to add entries for each
sub-domain as needed. If that’s the case, wouldn’t I have to restart
nginx each time a new entry is made? I plan to have sub-domains created
when users register. Will I have to restart?
Thanks now if I wanted to let a member who has a sub-domain on our
domain, “user.domain.com” map one of their own domains or sub-domains
using a cname. I would need to create a ServerAlias for their
sub-domain, in apache2 it would be something like below. So using the
regex probably wouldn’t be the best method, so just adding them as you
listed in the first reply is how to go about it?
In your example does that mean I would need to add entries for each
sub-domain as needed. If that’s the case, wouldn’t I have to restart
nginx each time a new entry is made? I plan to have sub-domains created
when users register. Will I have to restart?
No, just reload, which is safe.
But if that’s a problem, you can extract subdir with regex
in the same map, something like this:
Thanks now if I wanted to let a member who has a sub-domain on our
domain, “user.domain.com” map one of their own domains or sub-domains
using a cname. I would need to create a ServerAlias for their
sub-domain, in apache2 it would be something like below. So using the
regex probably wouldn’t be the best method, so just adding them as you
listed in the first reply is how to go about it?
Using those methods together is fine too. You can go either or both
ways.