1 Reply Latest reply on Jul 21, 2017 10:05 AM by Nicolas Ramos

    Connecting apache and Widfly using mod_cluster

    Ammar Al-Batool Newbie

      I am trying to setup mod_cluster as a reverse proxy for Wildfly 9. When I use http as a protocol (between mod_cluster and Wildfly), everything works just fine (forwarding requests to application server and detecting server).

       

       

      My problems come up when I try to wire mod_cluster and wildfly using ajp as a protocol. I checked mod_cluster-manager and it seemed that

      mod_cluster was connected to wildfly, but it couldn't forward

      requests to application server.

       

       

      I have the following configuration:

       

       

      - http server: Apache/2.4.18 (Ubuntu)

      - application server: Wildfly 9.0.2

      - mod_cluster: 1.3

       

       

      mod_cluster.conf

       

          PersistSlots on

          CreateBalancers 1

          MemManagerFile /opt/mod_cluster/logs

         

         

          EnableOptions

          AllowDisplay On

          AllowCmd On

          WaitForRemove 1

         

         

         

          UseAlias 1

          ServerAdvertise Off

         

          Listen *:5555

          <VirtualHost *:5555>

              <Directory />

                  Order deny,allow

                  Allow from 192.168.0.71

                  Allow from 192.168.0.71

                  Allow from 127

                  Require all granted

               </Directory>

               <Location /mcm>

                   SetHandler mod_cluster-manager

                   Allow from 192.168

                   Allow from all

               </Location>

               KeepAliveTimeout 300

               MaxKeepAliveRequests 0

               ManagerBalancerName mycluster

               #AdvertiseFrequency 5

               EnableMCPMReceive

         

          </VirtualHost>

         

         

         

          <VirtualHost *:80>

         

              ServerName my-app.org

              ServerAlias my-app.org

              ErrorLog /var/log/apache2/user.error.log

              LogLevel warn

              CustomLog /var/log/apache2/my_app.access.log combined

              ServerSignature On

         

              Redirect "/" https://my-app.org

              ProxyPreserveHost On

              SSLProxyEngine On

              ProxyPreserveHost On

              #ProxyPass /_error !

              #ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=on

              #ProxyPassReverse / balancer://mycluster

         

         

              <Location />

                  Order deny,allow

                  Allow from all

              </Location>

         

          </VirtualHost>

         

          <VirtualHost *:443>

         

              ServerName my-app.org

              ServerAlias my-app.org

              SSLEngine on

              SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem

              SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

              ErrorLog /var/log/apache2/user.ssl.error.log

              LogLevel warn

              CustomLog /var/log/apache2/my_app.ssl.access.log combined

              ServerSignature On

             

              SSLProxyEngine On

              ProxyPreserveHost On

              ProxyPass /_error !

              ProxyPass / balancer://mycluster stickysession=JSESSIONID|jsessionid nofailover=on

              ProxyPassReverse / balancer://mycluster

              <Location />

                  Order deny,allow

                  Allow from all

              </Location>

          </VirtualHost>

       

       

       

       

       

       

       

      Wildfly Configuration (relevant fragments):

       

       

      mod_cluster subsystem:

       

              <subsystem xmlns="urn:jboss:domain:modcluster:2.0">

                  <mod-cluster-config advertise-socket="modcluster"

                                      proxies="mc-prox1"

                                      advertise="false"

                                      sticky-session-force="true" load-balancing-group="mycluster" connector="ajp">

                      <dynamic-load-provider>

                          <load-metric type="cpu"/>

                      </dynamic-load-provider>

                  </mod-cluster-config>

              </subsystem>

       

       

       

      outbound-socket-binding:

       

              <outbound-socket-binding name="mc-prox1">

                  <remote-destination host="192.168.0.71" port="5555"/>

              </outbound-socket-binding>

       

      [EDIT]

       

      My AJP configuration:

      <socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:1500}">
        <socket-binding name="ajp" port="${jboss.ajp.port:0}" />
      .......
      </socket-binding-group>

       

      [EDIT2]

      When I set ajp port to 8009, it works. I want to use custom port number. Does anyone have a clue how to do it?