WebSockets

WebSockets is a method of providing bi-directional communication, similar to BOSH but with less overhead.

Configuration

WebSocket support is provided by mod_websocket, so uncomment or add "websocket" in your modules_enabled list to enable WebSockets.

With default HTTP settings the WebSocket connection endpoint will be avaliable at the following locations:

  • ws://example.com:5280/xmpp-websocket
  • wss://example.com:5281/xmpp-websocket

See documentation on HTTP settings for how to map HTTP Hosts to Prosody VirtualHosts, change the path or ports etc.

HTTP Proxy Passtrough

If you proxy WebSocket connections trough a HTTP proxy or server that handles HTTPS, you can set consider_websocket_secure = true to tell Prosody not to worry about the connections being unencrypted.

If you know how to configure other HTTP servers for WebSockets, let us know.

Nginx

location /xmpp-websocket {
    proxy_pass http://localhost:5280/xmpp-websocket;
    proxy_http_version 1.1;
    proxy_set_header Connection "Upgrade";
    proxy_set_header Host $host;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header X-Forwarded-For $remote_addr;
}