Configuring XMPP Federation (s2s)
Wed 22 April 2015 by Eric RichterContinuing my series on XMPP server configuration, this post will be on setting up server-to-server message passing using Prosody. It is assumed that there are two servers set up and configured in a similar fashion to the previous post.
About s2s
Well, like the last post, first allow me to introduce what this is, and why it is pretty cool. XMPP servers can create a network, where each node has its own set of users, configuration and chat rooms. Each edge would be one of these s2s links, so that users on two separate servers can communicate with each other.
There are two kinds of messages that XMPP servers can handle, Client-to-Server (c2s), and Server-to-Server (s2s).
c2s are the messages sent between a user and the server, which includes regular message, presences, etc.
s2s on the other hand, are those same types of messages, instead being sent from a server to another server.
Straightforward, no?
It is important to point out though that XMPP clients should NEVER send s2s messages to any server (ever), and servers should never send c2s messages to any client that is that is connected to that particular server.
So for example, let's say we have two servers, at xmpp.server.net and xmpp.derp.net, and user Foo Barington wants to send a message to Baz Spam.
The message Foo sends will still be sent to the server Foo exists on, NOT to the server Baz is on NOR Baz directly.

Why create a network?
Because I like rambling a lot before getting into the useful information, let us first consider the benefits and potential drawbacks. Negative first of course, the obvious question that should be asked is, "Well, that's really inefficent, requiring messages to have so many hops, why not just send to their server directly or to them etc.etc.etc". Yes, XMPP federation is slower. Furthermore, your messages are being passed between servers that are not under your control, how are you sure of their security practices?
Well, the major benefit to creating a network is that it compartmentalizes the userbase.
Say I have a bunch of friends that all want to communicate; I can spin up an XMPP server for all of us to use.
Then, if I meet someone else who has their own circle of friends, we don't need to migrate our users, nor do they need to migrate theirs.
Instead, we simply connect the servers and our users can now communicate.
If things go sour, one side can simply drop the s2s connection, and terminate the ability for them to communicate.
Furthermore, the two groups don't even need to use the same server software, so unionizing the two is very simple.
Now, why both have smaller servers and not just one giant public server? These do exist: jabber.org and gtalk are two major ones. However, these put you the user at the mercy of their configurations, and all the other users on that network. Setting up your own server allows you finer control on your community and uses, while still allowing communication to other services under the same interface.
Setting up s2s
Alright, Alright, I've rambled enough, how does one go on this magical journey. Well, please don't be mad at me when I say the following is all you need to do is add (on both servers):
s2s_secure_auth = false
s2s_insecure_domains = { "xmpp.otherserver.net", "xmpp.anotherserver.net" }
to your configuration file.
Also, make sure your modules_disabled array does not include s2s, or it is commented out (some default configurations may do so).
That module is loaded by default, and does not need to go in the modules_enabled array.
Now, this is for getting a SIMPLE network going.
However, it is obviously not secure, given the configuration option name.
I will discuss setting up a secure s2s connection in a future post on SSL.