9 Replies Latest reply on Sep 9, 2010 7:51 AM by Martin Dixon

    mod_cluster interfering with other VirtualHost requests

    Martin Dixon Newbie

      Am using mod_cluster on an apache server that needs to service a mixture of requests - some requests serviced by mod_cluster and forwarded to back-end jboss instances, other requests (for aliases and contexts not registered in mod_cluster) but setup as standard apache VirtualHost entries with DocumentRoot on the local apache server and ScriptAliasMatches for cgi scripts. The alias and contexts that are non mod_cluster/jboss obviously have no host entries in jboss/tomcat and do not show up in mod_cluster_manager.

       

      Behaviour is that when apache is restarted, the non mod_cluster contexts work fine for the first few seconds (before jboss registers it's aliases/contexts with mod_cluster on apache - ie before details appear on mod_cluster_manager page), but as soon as the jboss contexts are registered and mod_cluster starts servicing those requests the non mod_cluster requests stop working. There appears to be no output in the logs for non mod_cluster requests after that point - so looks like mod_cluster intercepts those requests and doesn't pass them on correctly.

       

      Example httpd config:

       

      ====================================

       

      <VirtualHost *:80>

      ServerName example.domain.com

      ServerAlias  example.alias.com

      DocumentRoot /store/example/www

      ScriptAliasMatch  ^/exec    /store/example/cgi/exec.cgi

      ScriptAlias  /cgi/  /store/example/cgi/

      AddHandler server-parsed .html .shtml .htm

      </VirtualHost>

       

      <Directory /store/example/cgi>

      SetHandler           perl-script
      PerlResponseHandler  ModPerl::Registry
      PerlOptions          +ParseHeaders
      Options              +ExecCGI -Indexes
      </Directory>

       

      CreateBalancers 0
      ManagerBalancerName balancer01

       

      Listen xxx.xxx.xxx.xxx:6666
      <VirtualHost xxx.xxx.xxx.xxx:6666>

         <Directory />
            Order deny,allow
            Deny from all
         </Directory>

      KeepAliveTimeout 60
      MaxKeepAliveRequests 0

      </VirtualHost>

       

      ====================================

       

      Have tried various CreateBalancer and ProxyPass options, but no luck getting mod_cluster to ignore the requests that it shouldn't handle as yet.

       

      Does mod_cluster support this scenario, or is there something obviously wrong with the configuration?

       

      Thanks,

        • 1. Re: mod_cluster interfering with other VirtualHost requests
          Jean-Frederic Clere Master

          Try UseAlias 1 and use <Alias>VirtualHostName</Alias> in the jboss <Host/> configuration.

          • 2. Re: mod_cluster interfering with other VirtualHost requests
            Martin Dixon Newbie

            Thanks for the reply. Your suggested UseAlias approach works for the domains/virtualHosts that are on one or the other, but still see the same problem for hosts that are present on both apache and jboss but use different contextRoots.

             

            For the example config i gave above, if i want apache/cgi scripts to handle requests to:

             

            example.domain.com/

            and

            example.domain.com/exec

             

            but I have a Host defined in jboss:

             

            <Host name="example.domain.com">
               <Alias>exampleAlias.domain.com</Alias>
            </Host>

             

            with a contextRoot of "/admin"  (<context-root> defined inside <jboss-web> in jboss-web.xml of .war)

             

            then the jboss/mod_cluster requests are passed through to jboss ok (eg example.domain.com/admin requests are serviced) but the requests that should be handled by apache (eg example.domain.com/exec) are still lost.

             

            (The Context /exec is not deployed on jboss and does not show up in mod_cluster_manager, although i do have a root context / deployed for a separate application with different alias)

             

            Is there a way to get mod_cluster and apache to handle the respective requests to the different Contexts for the same alias/domain correctly?

            • 3. Re: mod_cluster interfering with other VirtualHost requests
              Jean-Frederic Clere Master

              If example.domain.com/ is routed to jboss it is because you haven't ROOT in the excludedContexts properties.

              In case you need to have ROOT enabled you should use the NoProxy directive for the example.domain.com/exec something like:

              ProxyPass /exec !

              • 4. Re: mod_cluster interfering with other VirtualHost requests
                Jean-Frederic Clere Master

                If example.domain.com/ is routed to jboss it is because you haven't ROOT in the excludedContexts properties.

                 

                In case you need to have ROOT enabled you should use the NoProxy directive for the example.domain.com/exec something like:

                 

                ProxyPass /exec !

                • 5. Re: mod_cluster interfering with other VirtualHost requests
                  Martin Dixon Newbie

                  Thanks again for the reply. My excludedContexts include ROOT, but out of the multiple applications I have deployed on jboss, one has a contextRoot of "/".

                   

                  <property name="excludedContexts">${jboss.mod_cluster.excludedContexts:ROOT,admin-console,invoker,jbossws,jmx-console,juddi,web-console}</property>

                   

                  So, for the example config i quoted above:

                   

                  I have an application deployed on jboss with domain/alias "another.domain.com" and context-root "/" - both alias and root context show up in mod_cluster_manager correctly. When this application is deployed it stops requests to "example.domain.com" and "example.domain.com/exec" being serviced (but requests to "example.domain.com/admin/" are now handled ok after UseAlias=1 change).

                   

                  Maybe it is wrong for me to include ROOT in excludedContexts, but requests to different domains+contextRoots do not seem to be differentiated correctly:

                   

                  another.domain.com/ (deployed on jboss with root context) --> requests handled ok

                  example.domain.com/admin/ (deployed on jboss with context-root "admin") --> requests handled ok

                  example.domain.com/ (apache only with root context) --> requests not serviced

                   

                  Can mod_cluster differentiate a request to a root context between domainA and domainB?

                  • 6. Re: mod_cluster interfering with other VirtualHost requests
                    Jean-Frederic Clere Master

                    As I said before you have to use ProxyPassMatch regexp ! in the VirtualHost where you want / handled by httpd.

                    • 7. Re: mod_cluster interfering with other VirtualHost requests
                      Martin Dixon Newbie

                      All now working fine with combination of UseAlias, ProxyPass and ProxyMatch where needed.. Thanks!

                      • 8. Re: mod_cluster interfering with other VirtualHost requests
                        Konstantin Kasatkin Newbie

                        Hi Martin,

                        could you share working extracts from your config files (jboss-web.xml, server.xml, httpd.conf) for deployment a ear application to root context?

                        I can't figure out how to make an ear application to deploy to / (root) context.

                        • 9. Re: mod_cluster interfering with other VirtualHost requests
                          Martin Dixon Newbie

                          Hosts are defined as standard in the tomcat/jboss server.xml , for example:

                           

                          <Host name="host1.example.com">
                             <Alias>host2.example.com</Alias>
                             ...
                          </Host>

                           

                          jboss-web.xml needs no special mod_cluster config. Httpd config is same as i stated above in my first post to this thead, but with the following additions:

                           

                          UseAlias 1

                           

                          and depending on which requests you want mod_cluster to ignore and let apache handle instead, a combination of ProxyPass and/or ProxyPassMatch as needed.

                           

                          eg to have apache handle every request for a VirtualHost:

                           

                          ProxyPass  / !

                           

                          or use a regex to selectively bypass only certain requests:

                           

                          ProxyPassMatch  [regex] !