Rake and subdomains

Does Grails know anything about subdomains (i.e. subdomain.domain.com)? I do not see this discussed in the manual. Is this just an application server / web server problem? Can be attached to the Grail controllers, statically or dynamically?

+6
source share
3 answers

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.

+10
source

We run multiple Grails applications on the same host using different subdomains. In all cases, we use Apache to manage the Tomcat server and use mod jk or forward proxy to process applications in another Grails application. Most of them are fairly straightforward, which we have not figured out is launching applications at the root level for different domains, for example, http://app1.domain.com instead of http://app1.domain.com/app1

+1
source

The only thing I know about the subdomains in question is the tenant’s permission when using the plugin with several tenants. See http://tinyurl.com/6tuxwvs .

0
source

Source: https://habr.com/ru/post/908221/


All Articles