openfire-docker-compose/cluster_with_federation
Matthew Vivian a64e80e5d2
refactor: rename openfire.sql to clarify execution order
Renamed openfire.sql to 000-init-openfire.sql to make the initialisation order explicit in the filename. This helps when adding additional SQL scripts that need to run after the schema is created, as PostgreSQL executes files in /docker-entrypoint-initdb.d alphabetically.

The new openfire-integration-test repo uses this openfire-docker-compose repository as a base (using git submodules) for its tests but needs to reconfigure Openfire via the database before startup. To do this it overlays additional SQL files into this openfire-docker-compose repository's sql folders so they are run on startup. It has had to prefix its new SQL file with zz- to make sure it runs after the initialisation SQL file in our repository. This change should make future similar uses less complex/error-prone.
2025-01-06 15:47:48 +00:00
..
nginx Fix IPv6 configuration in nginx.conf files 2024-11-07 12:22:48 +01:00
plugins Clustering: use Hazelcast 5.5.0 2024-11-05 20:37:43 +01:00
plugins_for_otherdomain Move all the files into purpose-defined subdirectories 2022-07-27 14:47:41 +02:00
sql refactor: rename openfire.sql to clarify execution order 2025-01-06 15:47:48 +00:00
xmpp Clustering: use Hazelcast 5.5.0 2024-11-05 20:37:43 +01:00
README.md Add dualstack support 2024-11-05 09:47:10 +00:00
docker-compose-clustered.yml [chore] Remove obsolete version attribute from docker-compose yml files 2024-12-03 10:36:38 +00:00
docker-compose-network-dualstack.yml Add dualstack support 2024-11-05 09:47:10 +00:00
docker-compose-network-ipv4-only.yml Add dualstack support 2024-11-05 09:47:10 +00:00
start.sh Ipv6: Add `java.net.preferIPv6Addresses` property 2024-11-05 09:47:10 +00:00

README.md

Clustered configuration

Running ./start.sh will perform some cleanup then start the containers in a clustered configuration. When running, the system looks like this:

                   +--------------------------------------------------+
                   |           172.60.0.99                            |
                   |       +----------------+                         |
                   |       |                |+--------------+         |
(XMPP-C2S)  55222 -|-------|  Load Balancer |+-------+      |         |
(BOSH)      57070 -|       |                |        |      |         |
(BOSHS)     57443 -|       +----------------+        |      |         |
                   |           |                     |  172.60.0.30   |
                   |           |                     |  +--------+    |
                   |           |          +=============+        |    |- 5223 (XMPP-C2S)
                   |           |          |          |  | XMPP 3 |----|- 5263 (XMPP-S2S)
                   |           |          |          |  |        |    |- 9093 (HTTP-Admin)
                   |           |          |          |  +------+-+    |- 7073 (BOSH)
                   |           |          |          |         |      |
                   |      172.60.0.10     |     172.60.0.20    |      |
                   |      +--------+      |     +--------+     |      |
(XMPP-C2S)   5221 -|      |        +======+     |        |=====+      |- 5222 (XMPP-C2S)
(XMPP-S2S)   5261 -|------| XMPP 1 +============+ XMPP 2 |            |- 5262 (XMPP-S2S)
(HTTP-Admin) 9091 -|      |        |            |        |------------|- 9092 (HTTP-Admin)
(BOSH)       7071 -|      +----+---+            +----+---+            |- 7072 (BOSH)
                   |           |                     |                |
                   |           |                     |                |
                   |       +---+--+                  |                |
                   |       |      |                  |                |
(Database)   5432 -|-------|  DB  +------------------+                |
                   |       |      |                                   |
                   |       +------+                                   |
                   |      172.60.0.11                                 |
                   |                                                  |
                   +----------------172.60.0.0/24---------------------+

Note that the load balancer is configured to be less flappy, with the flappiness controlled by the nginx config, simulating simple round-robin DNS load balancing. Ports from individual servers are exposed and can be hit directly.

Openfire is configured with the following XMPP domain:

  • xmpp.localhost.example

Openfire is configured with the following hostnames:

  • xmpp1.localhost.example
  • xmpp2.localhost.example
  • xmpp3.localhost.example

The following users are configured:

  • user1 password
  • user2 password

The following MUC rooms are configured:

  • muc1
  • muc2

The federated domain

The start script will also instantiate a second XMPP domain that consists of one Openfire server. This will result in the following components to be added to the system as described above:

                   +------------------------+
                   |       172.60.0.110     |
                   |      +------------+    |
(XMPP-C2S)   5229 -|      |            |    |
(XMPP-S2S)   5269 -|------| OTHER XMPP |    |
(HTTP-Admin) 9099 -|      |            |    |
(BOSH)  7079/7449 -|      +------+-----+    |
                   |             |          |
                   |             |          |
                   |       +-----+----+     |
                   |       |          |     |
(Database)   5433 -|-------| OTHER DB |     |
                   |       |          |     |
                   |       +----------+     |
                   |       172.60.0.111     |
                   |                        |
                   +------172.60.0.0/24-----+

The additional Openfire is configured with the following XMPP domain:

  • otherxmpp.localhost.example

Openfire is configured with the following hostname:

  • otherxmpp.localhost.example

The following users are configured:

  • user1 password
  • user2 password

The following MUC rooms are configured:

  • muc1
  • muc2

Note that users and MUC rooms on the additional Openfire domain have a similar name to those on the cluster. This does not lead to collisions, as the domain-part of their JIDs will differ.

Network

The Docker compose file defines a custom bridge network with a single subnet of 172.60.0.0/24 for the clustered configuration.

When the -6 argument to ./start.sh is provided, then an additional subnet of fd23:0d79:d076::/64 is configured. Then, IPv6 is preferred for internal networking. Note that the IPv4 network remains in place, as Docker does not support IPv6-only containers.

When running with the optional -6 flag (that adds IPv6 support) the system looks like this:

                   +--------------------------------------------------+
                   |       [fd23:d79:d076::99]                        |
                   |           172.60.0.99                            |
                   |       +----------------+                         |
                   |       |                |+--------------+         |
(XMPP-C2S)  55222 -|-------|  Load Balancer |+-------+      |         |
(BOSH)      57070 -|       |                |        |      |         |
(BOSHS)     57443 -|       +----------------+        |      |         |
                   |           |                     | [fd23:d79:d076::30]
                   |           |                     |  172.60.0.30   |
                   |           |                     |  +--------+    |
                   |           |          +=============+        |    |- 5223 (XMPP-C2S)
                   |           |          |          |  | XMPP 3 |----|- 5263 (XMPP-S2S)
                   |           |          |          |  |        |    |- 9093 (HTTP-Admin)
                   |           |          |          |  +------+-+    |- 7073 (BOSH)
                   |           |          |          |         |      |
                   |  [fd23:d79:d076::10] | [fd23:d79:d076::20]|      |
                   |      172.60.0.10     |     172.60.0.20    |      |
                   |      +--------+      |     +--------+     |      |
(XMPP-C2S)   5221 -|      |        +======+     |        |=====+      |- 5222 (XMPP-C2S)
(XMPP-S2S)   5261 -|------| XMPP 1 +============+ XMPP 2 |            |- 5262 (XMPP-S2S)
(HTTP-Admin) 9091 -|      |        |            |        |------------|- 9092 (HTTP-Admin)
(BOSH)       7071 -|      +----+---+            +----+---+            |- 7072 (BOSH)
                   |           |                     |                |
                   |           |                     |                |
                   |       +---+--+                  |                |
                   |       |      |                  |                |
(Database)   5432 -|-------|  DB  +------------------+                |
                   |       |      |                                   |
                   |       +------+                                   |
                   |      172.60.0.11                                 |
                   |  [fd23:d79:d076::11]                             |
                   |                                                  |
                   +----------------172.60.0.0/24---------------------+
                                 fd23:0d79:d076::/64

The federated domain, with IPv6 enabled, looks like this:

                   +------------------------+
                   |  [fd23:d79:d076::110]  |
                   |       172.60.0.110     |
                   |      +------------+    |
(XMPP-C2S)   5229 -|      |            |    |
(XMPP-S2S)   5269 -|------| OTHER XMPP |    |
(HTTP-Admin) 9099 -|      |            |    |
(BOSH)  7079/7449 -|      +------+-----+    |
                   |             |          |
                   |             |          |
                   |       +-----+----+     |
                   |       |          |     |
(Database)   5433 -|-------| OTHER DB |     |
                   |       |          |     |
                   |       +----------+     |
                   |       172.60.0.111     |
                   |  [fd23:d79:d076::111]  |
                   |                        |
                   +------172.60.0.0/24-----+
                        fd23:0d79:d076::/64

Removing a node from the network

To remove a node from the network run the following command:

docker network disconnect NETWORK-NAME CONTAINER-NAME

For example:

docker network disconnect openfire-testing_openfire-federated-net openfire-testing_xmpp1_1

Adding a node to the network

To add a node to the network fun the following command:

docker network connect NETWORK-NAME CONTAINER-NAME

For example:

docker network connect openfire-testing_openfire-federated-net openfire-testing_xmpp1_1