Virtual hosting with Ejabberd

By Abhijit Menon-Sen <>

I have been running Ejabberd for some time. Recently, some friends asked me if I would serve Jabber for their domains too, and I was pleased to find that relatively easy to do.

Let's suppose I want to serve foo@example.org. The first step is to add example.org to the list of hostnames in ejabberd.cfg:

{hosts, ["toroid.org", "example.org"]}

Next, I have to restart Ejabberd to make it accept the new hostname.

Then I use ejabberdctl to register the new JID, while soothing irate users whose connection to the server was dropped during the previous step, and wishing that the server could just accept arbitrary hostnames in JIDs and do the necessary magic internally without needing to be restarted.

ejabberdctl register foo example.org somepassword

Now the new user should be able to login to the server using their favourite Jabber client.

Finally, the following SRV records must be added to the example.org zone in order to delegate XMPP/Jabber service to my server.

_jabber._tcp.example.org.      SRV 0 0 5222 xmpp.toroid.org.
_xmpp-client._tcp.example.org. SRV 0 0 5222 xmpp.toroid.org.
_xmpp-server._tcp.example.org. SRV 0 0 5269 xmpp.toroid.org.

Once the world can see these records, anyone trying to contact someone at example.org will talk to my server (that is, unless it is an unpatched Net::XMPP client).