It doesn't matter what host access is for the Java web application.
Suppose you have several clients shared on one host, for example. customer1.yourhost.com, customer2.yourhost.com etc., and all customers will have the same functionality.
In the simplest case, I will write that you just use write a filter that will always put some query variable, for example:
def filters = { all(controller:'*', action:'*') { before = { if (request.serverName.contains(".")) { def clientName = request.serverName.substring(0, request.serverName.indexOf(".")) request.currentClient = Client.findByClientName(clientName) // eg } } } }
Then, anywhere you can check request.currentClient
for the currently available subdomain.
However, if it gets more complicated, check out some multi-tenant plugins for grails.
If you want to have different functionality for each subdomain, for example. help.yourhost.com and www.yourhost.com, I would suggest writing independent grails applications. Then you configure the NGINX server to redirect these requests to the appropriate application running on your application server.
Chris source share