1 2 Previous Next 18 Replies Latest reply on Feb 16, 2012 12:23 PM by rhusar

    mod_cluster and ProxyPass directives

    syncmaster2009

      Ok, still doing some tests, and after solving and putting to work mod_cluster with multiple Jboss Clusters and multiple virtual sites on Apache HTTP, I have another issue.

       

      I'm running the 1.1.3 release with Apache 2.2.15.

       

      So I'm using the following settings:

       

      CreateBalancer 0

      UseAlias 1

       

      According to this I don't need to add ProxyPass directives to the Apache Virtual sites.

      In fact everything arriving to virtual site is forwarded to the correct Jboss Cluster with the same alias/hostname of the virtual site.

       

      But for one specific virtual site I need that the request for a specific URL path should be delivered to another backend server that is not Jboss nor a cluster. In fact it is Tomcat 7.

       

      I've tried three solutions but all of them failed.

       

      1st) Added to the virtual site the following directives:

       

           ProxyPass /documentation http://backend:8800/documentation

           ProxyPassReverse /documentation http://backend:8800/documentation

       

      This fails, because it's still delivered to the Jboss cluster, not to the backend server

       

      2nd) Same thing as above but with a ProxyMatch directive

       

           ProxyMatch /documentation !

           ProxyPass /documentation http://backend:8800/documentation

           ProxyPassReverse /documentation http://backend:8800/documentation

       

      Doesn't work because now Apache thinks that it should be the one delivering the URL.

       

      3rd) Added the Tomcat 7 to the mod_cluster cluster with the same virtual site name/alias and a specific jvm route.

       

      The new TC7 does appear on mod_cluster status page, and the application also appears, but 503 error appears.

        According to the logs the request is correctly routed to the TC7 but because mod_cluster associates a load=-1 to the route and off course it fails.

       

      I've read somewhere that TC doesn't support mod_cluster running in HA/cluster mode... Is this correct?

       

      Any ideas how I can solve this issue? Thanks in advance

        • 1. Re: mod_cluster and ProxyPass directives
          jfclere

          "load=-1"

           

          There should be a problem between httpd and TC7, check the error_log use debug and retry.

          • 2. Re: mod_cluster and ProxyPass directives
            syncmaster2009

            I have no errors worthy of detail except that all workers in error state (just one for tc7) and load=-1

            • 3. Re: mod_cluster and ProxyPass directives
              syncmaster2009

              Ok, for 3), problem solved. The Tomcat AJP port was coliding with one of the Jboss instances (ports-default).

               

              So it's working.

               

              For 1) or 2) is there a solution if I don't want to use an application server and join it to the mod_cluster?

              • 4. Re: mod_cluster and ProxyPass directives
                jfclere

                Try to remove the ProxyPass directive and rely on mod_cluster only.

                • 5. Re: mod_cluster and ProxyPass directives
                  syncmaster2009

                  That solution only is possible if the other servers are Jboss/Tomcat family... I I have another Apache or Websphere or Weblogic, I can't do that...

                  • 6. Re: mod_cluster and ProxyPass directives
                    syncmaster2009

                    Regarding solution 3), letting mod_cluster do all the work, in my mix of Jboss server 5.1 and Tomcat 7, sometimes request get mangled and go to the wrong server wich results in Page not founds...

                     

                    So it's also not a solution... :-(

                    • 7. Re: mod_cluster and ProxyPass directives
                      jfclere

                      A mix of AS5.1 and TC7 should work if not that is a configuration error, webapp timeout or bug in mod_cluster.

                      • 8. Re: mod_cluster and ProxyPass directives
                        syncmaster2009

                        The strange thing is that I've done all my tests on Linux OS (I'm a Linux user...) and everything worked fine, but on the customer that is using W2008 R2 64bit it has the above described behavior... Strange..

                         

                        I'm going to look at it more time...

                        • 9. Re: mod_cluster and ProxyPass directives
                          syncmaster2009

                          Not sure, but it might be a bug...

                           

                          Let's see:

                           

                          I have two Jboss servers J1 and J2, and one Tomcat Server T7.

                           

                          On J1 and J2 I have application A1 that at first access it generates a JSESSIONID cookie.

                           

                          On T7 I have application B1 that also generates a cookie, and application B2 that is plain HTML pages, and so no cookies.

                           

                          Acessing to the URL of application A1, it seems that it always go to the JBoss servers, and after the cookie is set the session gets sticky and so no problems.

                           

                          If acessing URL of application B1, while it hits Jboss servers, it gives page not found, and refreshing moves the server that is being hit, but if it hits Tomcat, the cookie is set and after that it sticks to the T7 server, so no issues.

                           

                          Now for the application B2, because it never sets a cookie it works ok, and the it fails, works ok and it fails, and this happens because mod_cluster is choosing Jboss or TC7, the Jboss and the TC7, and so on...

                           

                          It seems that the logic for selecting the server is failing to select the correct destination server based on the URL...

                           

                          Now, I can only see this behaviour on Windows server platform (huggg....) and not on my Linux test machines.... Strange.

                           

                          I can add a log, if necessary.

                          • 10. Re: mod_cluster and ProxyPass directives
                            erhard

                            I would like to use a setup like this in order to use mod_cluster in a general-puropse Apache-server:

                             

                            {code}

                            LoadModule proxy_cluster_module modules/mod_proxy_cluster.so

                            LoadModule manager_module modules/mod_manager.so

                             

                            ProxyPass        /togoogle http://www.google.com

                            ProxyPassReverse /togoogle http://www.google.com

                             

                            ProxyPass        /bla balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On

                            ProxyPassReverse /bla balancer://mycluster

                             

                            CreateBalancers 1

                             

                            <IfModule manager_module>

                              Listen 192.168.40.129:6666

                              ManagerBalancerName mycluster

                              <VirtualHost 192.168.40.129:6666>

                              ServerName devjava

                              LogLevel debug

                             

                                <Location />

                                 Order deny,allow

                                 Deny from all

                                 Allow from 192.168

                                </Location>

                             

                                KeepAliveTimeout 300

                                MaxKeepAliveRequests 0

                                AdvertiseFrequency 5

                             

                                <Location /mod_cluster_manager>

                                   SetHandler mod_cluster-manager

                                   Order deny,allow

                                   Deny from all

                                   Allow from all

                                </Location>

                             

                              </VirtualHost>

                            </IfModule>

                            {code}

                             

                            When I now get http://localhost/togoogle, mod_cluster rewrites the url to balancer://mycluster/togoogle and finally calls my JBoss: http://192.168.123.231:8080/togoogle. mod_cluster seems to highjack the whole Apache(?)

                            When I do a similar setup with mod_proxy_balancer:

                             

                            {code}

                            LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

                             

                            ProxyPass        /togoogle http://www.google.com

                            ProxyPassReverse /togoogle http://www.google.com

                             

                            ProxyPass        /jboss balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=On

                            ProxyPassReverse /jboss balancer://mycluster

                             

                            <Proxy balancer://mycluster>

                              BalancerMember http://192.168.40.129:8080

                            </Proxy>

                            {code}

                             

                            I get Google with http://localhost/togoogle and my JBoss with http://localhost/jboss as expected. I think it would be great if this would work also with mod_cluster.

                            Apearently the translation in the ProxyPath directive between the fake name (/togoogle) and real name (http://www.google.com) is not done with mod_cluster. With mod_proxy_balancer this is done in mod_proxy.c: proxy_trans():

                             

                            {code}

                            ap_hook_translate_name(proxy_trans, aszSucc, NULL, APR_HOOK_FIRST);

                            ...

                            static int proxy_trans(request_rec *r)

                                        ...

                                        len = alias_match(r->uri, fake);

                             

                                        if (len != 0) {

                                            ...

                                            found = apr_pstrcat(r->pool, "proxy:", real,

                                                                use_uri + len, NULL);

                                        }

                                        ...

                            {code}

                             

                            With mod_cluster the hook ap_hook_translate_name() seems to be overwritten by mod_proxy_cluster.c:proxy_cluster_trans()

                             

                            {code}

                            ap_hook_translate_name(proxy_cluster_trans, aszPre, aszSucc, APR_HOOK_FIRST);

                            {code}

                             

                            which doesn't do the translation between fake and real name.

                             

                            So is there a fundamental problem in supporting the ProxyPass like mod_proxy_balancer does, is it planned to be implemented or is there just another way to configure it?

                            • 11. Re: mod_cluster and ProxyPass directives
                              jfclere

                              You have excluded ROOT from the context in the jboss configuration?

                              • 12. Re: mod_cluster and ProxyPass directives
                                erhard

                                I'm not sure that I understand you correctly. I didn't exclude anything on purpose. JBoss is pretty much configured as default. The ROOT-Application is accessible on http://192.168.123.231:8080/ and mod_cluster is configured as shown above (without ProxyMatch !... or similar).

                                • 13. Re: mod_cluster and ProxyPass directives
                                  jfclere

                                  http://docs.jboss.org/mod_cluster/1.2.0/html/java.properties.html

                                   

                                  If you haven't excluded ROOT than everything will go to jboss and the logic of Proxypass/ProxyPassReverse are skipped.

                                  • 14. Re: mod_cluster and ProxyPass directives
                                    erhard

                                    Ok, I think I understand what you mean now, but in this case I kept the defaults and ROOT is in the excluded-contexts by default. My mod_cluster config in JBoss is:

                                     

                                    {code}

                                    [standalone@192.168.123.231:9999 /] ls subsystem=modcluster/mod-cluster-config=configuration

                                    ssl                                                                                  advertise=true

                                    advertise-socket=modcluster                                                          auto-enable-contexts=true

                                    balancer=mycluster                                                                   excluded-contexts=ROOT,admin-console,invoker,jbossws,jmx-console,juddi,web-console

                                    flush-packets=false                                                                  flush-wait=-1

                                    max-attemps=1                                                                        node-timeout=-1

                                    ping=10                                                                              proxy-list=/

                                    socket-timeout=20                                                                    sticky-session=1

                                    sticky-session-force=false                                                           sticky-session-remove=false

                                    stop-context-timeout=10                                                              ttl=60

                                    {code}

                                     

                                    I use the standalone-config.

                                    Aside from this I don't understand why excluding ROOT (/) from the target (jboss) should make a difference on the source context (apache). In my opinion it would be a useful configuration to write:

                                    ProxyPass        /jboss balancer://mycluster

                                    and send everything that starts with /jboss to the cluster. However, this is not my concern right now.

                                    1 2 Previous Next