Does Grails know anything about sub-domains (i.e. subdomain.domain.com) ? I don't see it discussed in the manual. Is this purely an app server/web server issue? Can be tied into grails controllers, either statically or dynamically?
It does not matter which host is accessed for a java web application.
Supposing you have multiple clients separated on one host, e.g. customer1.yourhost.com, customer2.yourhost.com, etc. and all clients will have same functionalities.
In the simplest case I propse, that you just use write a filter, which will always put some request variable, like this:
def filters = {
all(controller:'*', action:'*') {
before = {
if (request.serverName.contains(".")) {
def clientName =
request.serverName.substring(0, request.serverName.indexOf("."))
request.currentClient = Client.findByClientName(clientName) // e.g.
}
}
}
}
Then at any place you can check request.currentClient
for the current accessed subdomain.
However if it gets more complicated have a look at some multi-tenant plugins for grails.
If you want to have different functionalities for each subdomain e.g. help.yourhost.com and www.yourhost.com, I would propose that you write independent grails applications. You then setup a NGINX server to redirect those requests to the appropriate application running on your application server.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With