Tech pages/XEP-0368

Here is a sample sslh.conf (Using at least sslh 1.18) to support XEP-0368 among other things:

verbose: false; foreground: true; inetd: false; numeric: true; transparent: false; timeout: "2"; user: "nobody"; pidfile: "/run/sslh.pid";


 * 1) Note: I had to use IPs everywhere and not hostnames

listen: (   { host: "0.0.0.0"; port: "443"; }, );
 * 1) List of interfaces on which we should listen

protocols: (    { name: "tls";     host: "127.0.0.1"; port: "442";  alpn_protocols: [ "h2", "http/1.1" ]; },                 # https most common case     { name: "tls";     host: "127.0.0.1"; port: "5223"; alpn_protocols: [ "xmpp-client" ]; },                    # check for XEP-0368 xmpp tls (this needs to be above SNI check below because XEP-0368 would send example.org in SNI)     { name: "tls";     host: "127.0.0.1"; port: "442";  sni_hostnames:  [ "www.example.org", "example.org" ]; }, # specific hostnames go to https     { name: "tls";     host: "127.0.0.1"; port: "994";  sni_hostnames:  [ "imap.example.org" ]; },               # other hostnames go to imaps     { name: "tls";     host: "127.0.0.1"; port: "442"; },                                                        # anything else TLS assume for https     { name: "ssh";     host: "127.0.0.1"; port: "22"; },                                                         # ssh goes to ssh { name: "xmpp";   host: "127.0.0.1"; port: "5222"; },                                                       # xmpp goes to regular xmpp port { name: "timeout"; host: "127.0.0.1"; port: "442"; }                                                        # send everything unknown to https );
 * 1) in this example:
 * 2) 5223 is a "direct-tls" xmpp port (prosody legacy_ssl_ports, ejabberd listen with tls: true)
 * 3) 442 is a https port (nginx, apache, etc)
 * 4) 22 is an ssh port (openssh)
 * 5) 5222 is a regular/plain/starttls xmpp port (prosody c2s_ports, ejabberd listen with starttls: true)
 * 6) 994 is "direct-tls" imap port, imaps (dovecot etc)

on-timeout: "timeout"; # if timeout elapses (2 seconds here) go to https

This should now be possible with nginx following something like this: http://mailman.nginx.org/pipermail/nginx/2018-March/055798.html https://nginx.org/en/docs/stream/ngx_stream_ssl_preread_module.html Remove this blurb when actual example documentation is added.

Another (incorrectly named) example can be found at the Debian Wiki

You then need to setup your SRV Records so clients can find it, personally I have mine set up like so (for a JID like me@example.org):

_xmpps-client._tcp.example.org. 86400 IN SRV 5 0 443  xmpp.example.org. _xmpp-client._tcp.example.org. 86400 IN SRV 10 0 443 xmpp.example.org. _xmpp-client._tcp.example.org. 86400 IN SRV 15 0 5222 xmpp.example.org.

This prioritizes XEP-0368 TLS over port 443 first, then plain XMPP over 443 next, and lastly plain XMPP over 5222. A client that doesn't support XEP-0368 just skips the first record.

Please note the target can be anything, example.org, xmpp.example.org, or some.unrelated.domain.net, just as long as it's listening on those ports and has a valid certificate for example.org in this case.

If you have any questions feel free to ask the author of XEP-0368 via email, XMPP, or the nick moparisthebest in the [xmpp:xsf@muc.xmpp.org?join XSF MUC]