0

I've successfully created a WildFly cluster with 3 hosts in domain mode. Now I'm trying to get the mod_cluster subsystem without apache or other server in the middle, as I've seen it's possible, but I haven't found any recent documentation to accomplish that.

I've tried several ways and configs but none of them worked. Apps and persistence units are deployed and configured on master and replicated to slaves by the master, and context is accesible on all servers.

But if I try to get the context on port 80 (load balancer), all I got is a 404. Also, it doesn't show the "welcome to WildFly" startup page for no-context requests, so loadbalancer group isn't "connecting" to main-server-group and it's deployed apps.

Any help would be very appreciated. Here's my topology: image

2 Answers2

0

Additional information the static modcluster config did not work for me in wildfly 26 in docker swarm environment.

Docker swarm version information:

NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:44:13 2021
  OS/Arch:          linux/amd64
  Experimental:     true
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

I had to add the "any" interface to the domain.xml:

    <interfaces>
        ...
        <interface name="any">
            <inet-address value="0.0.0.0"/>
        </interface>
    </interfaces>

And change the startup arguments in both the master and slave servers.

Master:

export MY_IP=192.168.105.1
bin/domain.sh --host-config=host-master.xml -b $MY_IP -bmanagement 0.0.0.0 -bprivate $MY_IP

Slave:

export MY_IP=192.168.105.2
bin/domain.sh --host-config=host-slave.xml -b $MY_IP -bmanagement 0.0.0.0 -Djboss.domain.master.address=192.168.105.1
0

You don't need to use the Apache httpd for load-balancing, but you still need to use a load balancer. You can start a dedicated Wildfly server which will work as the load balancer within your domain. There is a ready-to-use profile called load-balancer within the default domain configuration file (domain.xml).

Steps to add a WildFly load balancer on the HTTP default port (80):

1) Edit domain.xml - fill the expected port number in the socket-binding-group element for load-balancer-sockets:

<socket-binding-group name="load-balancer-sockets" default-interface="public">
    <socket-binding name="http" port="80"/>
    <socket-binding name="https" port="443"/>
    <socket-binding name="mcmp-management" interface="private" port="${jboss.mcmp.port:8090}"/>
    <socket-binding name="modcluster" interface="private" multicast-address="${jboss.modcluster.multicast.address:224.0.1.105}" multicast-port="23364"/>
</socket-binding-group>

2) Edit domain.xml - add a new server-group for your load-balancer(s). Use load-balancer profile and load-balancer-sockets socket binding group for it. Example:

<server-groups>
    <server-group name="main-server-group" profile="ha">
        <socket-binding-group ref="ha-sockets"/>
    </server-group>
    <server-group name="load-balancer-group" profile="load-balancer">
        <socket-binding-group ref="load-balancer-sockets"/>
    </server-group>
</server-groups>

3) edit host.xml - add a new server which will be the load balancer - i.e. add it to the new load-balancer-group:

<servers>
    <server name="server-one" group="main-server-group"/>
    <server name="server-two" group="main-server-group" auto-start="true">
        <socket-bindings port-offset="150"/>
    </server>
    <server name="load-balancer" group="load-balancer-group" auto-start="true"/>
</servers>

4) If you use port numbers lower than 1024 on Linux like systems, then run the domain with a privileged system account (e.g. by using sudo):

sudo bin/domain.sh

You should have your domain including the load balancer successfully running now.

Update 1:

Troubleshooting

Make sure, all the bind interfaces are properly published (e.g. the private one on the load balancer!)

Host controller:

export MY_IP=192.168.105.1
bin/domain.sh --host-config=host-master.xml -b $MY_IP -bmanagement $MY_IP -bprivate $MY_IP

Slave:

export MY_IP=192.168.105.2
bin/domain.sh --host-config=host-slave.xml -b $MY_IP -bmanagement $MY_IP -Djboss.domain.master.address=192.168.105.1

If you use the host-master.xml as the host config for the load balancer, make sure you've added the public interface to it.

<interface name="public">
    <inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>

If your environment doesn't support multicast (e.g. clouds or docker environments), use e.g. static modcluster discovery config:

bin/jboss-cli.sh <<EOT
embed-host-controller
/socket-binding-group=ha-sockets/remote-destination-outbound-socket-binding=proxy1:add(host=192.168.105.1, port=8090)
/profile=ha/subsystem=modcluster/proxy=default:write-attribute(name=advertise, value=false)
/profile=ha/subsystem=modcluster/proxy=default:list-add(name=proxies, value=proxy1)
EOT

Test configuration with a simple <distributable/> application. I usually use a simple request counter app. It's a single JSP so it's easy to check it source code directly within the war file:

wget https://github.com/kwart/secured-webapp-template/releases/download/single-jsp-counter-distributable/counter-distributable.war
bin/jboss-cli.sh <<EOT
embed-host-controller
deploy counter-distributable.war --server-groups=main-server-group

Then test it by pointing your browser to http://192.168.105.1:8080/counter-distributable/ and also http://192.168.105.1/counter-distributable/

kwart
  • 161
  • 4
  • Thank you for your time, but I already had very close config to yours. Even so, I've replaced the only one difference (mcmp-management port). If you wish, you could take a look at topology image in OP: https://i.stack.imgur.com/qrmUz.jpg which represents exactly what you say and is what I actually have. So, http://192.168.105.1:8080/App and http://192.168.105.2:8082/App, for example, works fine, but http://192.168.105.191/App returns a 404. – Rafael Alcaide Aug 28 '19 at 13:04
  • I've updated the answer, check the Troubleshooting section. – kwart Aug 28 '19 at 15:28
  • Thank you very much! The only thing needed was expose the private interface on master. – Rafael Alcaide Aug 29 '19 at 06:14