Hacker News new | ask | show | jobs
by nly 3981 days ago
haproxy can do this out of the box. I've been using it for some time to put SSH on port 443 as a backup (not an alternative).

    frontend mux
        mode		    tcp
        bind                EXTERNAL_IP_HERE:443
        acl                 is_tls req.ssl_ver gt 3
        acl                 is_ssh payload(0,8) -m str SSH-2.0-
        tcp-request         inspect-delay 5s
        tcp-request	    content accept if is_ssh
        tcp-request         content accept if is_tls
        use_backend         ssh if is_ssh
        use_backend	    https if is_tls
where 'ssh' and 'https' are tcp mode backends.