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 The first step is to add to the list of hostnames in ejabberd.cfg:

{hosts, ["", ""]}

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 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 zone in order to delegate XMPP/Jabber service to my server.      SRV 0 0 5222 SRV 0 0 5222 SRV 0 0 5269

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