Basic scenario (I'm using real life domain names here):
- XMPP server is xmpp.yaxim.org serving the domain yax.im via SRV
- web server is yaxim.org running apache
We want to configure the web chat at https://yaxim.org/chat/ and to allow anon logins. For this, we need to configure prosody, apache and the webchat client accordingly.
Prosody: Anonymous Logins and BOSH
Enable BOSH in prosody.cfg
and create an
anonymous virtual host:
modules_enabled = {
...
-- HTTP modules
"bosh"; -- Enable BOSH clients, aka "Jabber over HTTP"
...
}
-- add at the end:
-- webchat anon login
VirtualHost "anon.yax.im"
authentication = "anonymous"
Apache 2 Reverse Proxy
The web client wants to interact with one domain only, therefore we need to
forward all BOSH requests from the client via the yaxim.org web server. Apache
has mod_proxy
for this.
Enable mod_proxy:
# cd /etc/apache2/mods-enabled
# ln -s ../mods-available/proxy.load
# ln -s ../mods-available/proxy.conf
# ln -s ../mods-available/proxy_http.load
Activate the proxy in apache's configuration. We only want this to work via HTTPS, so we add it to the yaxim.org:443 VirtualHost:
<VirtualHost yaxim.org:443>
...
# web chat proxy support
SSLProxyEngine On
ProxyPass /http-bind/ https://xmpp.yaxim.org:5281/http-bind/
ProxyPassReverse /http-bind/ https://xmpp.yaxim.org:5281/http-bind/
</VirtualHost>
Minimal Webchat Client
The prosody devs have an outdated, deprecated, buggy(?) webchat client you can easily drag & drop:
# cd /srv/yaxim.org/www/
# wget https://prosody.im/files/chat.tar.gz
# tar xzf chat.tar.gz
# cd chat/
All we need to do is to configure it, in index.html
:
var conn = new Strophe.Connection("/http-bind/");
var host = "anon.yax.im";
var room = "yaxim@chat.yax.im";