How to deploy multiple Grails apps on one Tomcat + Apache?

后端 未结 2 344
渐次进展
渐次进展 2021-02-02 01:09

I\'ve read the several questions on StackOverflow and googled several hours but I can\'t find a complete and clear answer to my problem of deploying multiple Grails apps on one

相关标签:
2条回答
  • 2021-02-02 02:00

    I struggled with this a while back and managed to get something that works ok. It doesn't use mod_jk though, I opted for mod_proxy. I also had a slightly different set up in Tomcat (mine is version 6 btw), where I added multiple connectors as well as the Host declarations you have.

    Try the following -

    In tomcat server.xml:

    <!-- I opted for a shared thread pool so both apps share same resources - optional -->
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="250" minSpareThreads="40"/>
    
    
    <Connector port="8081" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8444"
               executor="tomcatThreadPool"
               proxyName="www.domain1.com"
               proxyPort="80"/>
    <Connector port="8082" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8445"
               executor="tomcatThreadPool"
               proxyName="www.domain2.com"
               proxyPort="80"/>
    
      <Host name="www.domain1.com" appBase="vhosts/domain1" unpackWARs="true"
            autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
                <Alias>domain1.com</Alias>
      </Host>
      <Host name="www.domain2.com" appBase="vhosts/domain2" unpackWARs="true"
            autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
                <Alias>domain2.com</Alias>
      </Host>
    

    In Apache:

    <VirtualHost *:80>
      ServerName www.domain1.com
      ServerAlias www.domain1.com
    
      ProxyRequests Off
    
      ErrorLog /var/log/apache2/error-domain1.log
    
      <Directory proxy:http://www.domain1.com:80>
            Order Allow,Deny
            Allow from all
      </Directory>
    
      <Proxy www.domain1.com:80>
        Order deny,allow
        Allow from all
      </Proxy>
      ProxyPass / http://localhost:8081/
      ProxyPassReverse / http://localhost:8081/
      ProxyPreserveHost On
    </VirtualHost>
    
    <VirtualHost *:80>
      ServerName www.domain2.com
      ServerAlias www.domain2.com
    
      ProxyRequests Off
    
      ErrorLog /var/log/apache2/error-domain2.log
    
      <Directory proxy:http://www.domain2.com:80>
            Order Allow,Deny
            Allow from all
      </Directory>
    
      <Proxy www.domain2.com:80>
        Order deny,allow
        Allow from all
      </Proxy>
      ProxyPass / http://localhost:8082/
      ProxyPassReverse / http://localhost:8082/
      ProxyPreserveHost On
    </VirtualHost>
    

    Make sure mod_proxy is enable for your Apache server. It was a while ago when I got this working, so I'm sure if everything is needed in that config - once I get it working I tend to forget stuff :)

    Hope that helps, Chris.

    0 讨论(0)
  • 2021-02-02 02:11

    we have two Grails Web App running in production under the same tomcat

    That was easy to do with tomcat 6

    The difference I see with your server.xml is the name of the apps here what we have :

    <Host name="www.domain1.com" appBase="[tomcat_root_dir]/www.domain1.com/webapps" unpackWARs="true"
        autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
    </Host>
    <Host name="www.domain2.com" appBase="[tomcat_root_dir]/www.domain2/webapps" unpackWARs="true"
        autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false">
    </Host>
    

    Then we have two directories domain1.com and domain2.com in tomcat root dir In each directory, we have a webapps dir which holds only a ROOT.war file for each app

    Hope that helps

    Cheers

    Grooveek

    0 讨论(0)
提交回复
热议问题