This is pseudo code, the idea should be obvious, a sslh daemon for nginx, ideas, hacks, thoughts?? Stream has been augmented with more variable support so maybe the echo module doesn't need too much new things to get this working.
stream {
upstream backendssh {
server 192.168.1.2:22;
server 192.168.1.3:22;
}
upstream backendhttp {
server 192.168.1.2:80;
server 192.168.1.3:80;
}
server {
listen 1234;
echo_read_buffer_size 32b;
echo_read_timeout 10s;
echo_read_bytes 4;
set $stream_passed = echo -n 'GET|POST';
echo_request_data;
echo_flush;
content_by_echo '
if ngx.var.stream_passed then
ngx.var.stream_pass = 'backendhttp'
end
if not ngx.var.stream_passed then
ngx.var.stream_pass = 'backendssh'
end
';
proxy_pass http://$stream_pass;
}
}