My question is a bit different than serve ssh & https at the same time or redirect http requests to ssh. I don't want to multiplex the stream. I do have a virtual server to "spare" instead.
What I am thinking if it is possible, to have different virtual server(s) that I can always connect through ssh, while others can always connect through https. No multiplexing; clean/direct solutions, no decision taking. So for example the server web.myserver.com will be am https-only server and ssh.myserver.com a ssh-only server.
Not giving extra "stream overhead" would also be desired, if possible. In my eyes the stream top-level directives seems to have this overhead.
EDIT: to add more info what have I tried up to now:
On the stream{} part of the configuration I put this code:
upstream ssh {
server 192.168.1.5:22;
}
server {
listen 443;
listen [::]:443;
proxy_pass ssh;
}
and when I tried to connect to ssh I got this log information:
debug2: resolving "***" port 443
debug3: resolve_host: lookup ***:443
debug3: ssh_connect_direct: entering
debug1: Connecting to *** [***] port 443.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: Connection established.
...
debug1: Local version string SSH-2.0-OpenSSH_9.2
debug1: kex_exchange_identification: banner line 0: HTTP/1.1 400 Bad Request
debug1: kex_exchange_identification: banner line 1: Server: nginx/1.18.0
debug1: kex_exchange_identification: banner line 2: Date: Thu, 09 Mar 2023 15:10:38 GMT
debug1: kex_exchange_identification: banner line 3: Content-Type: text/html
debug1: kex_exchange_identification: banner line 4: Content-Length: 157
debug1: kex_exchange_identification: banner line 5: Connection: close
debug1: kex_exchange_identification: banner line 6:
debug1: kex_exchange_identification: banner line 7: <html>
debug1: kex_exchange_identification: banner line 8: <head><title>400 Bad Request</title></head>
debug1: kex_exchange_identification: banner line 9: <body>
debug1: kex_exchange_identification: banner line 10: <center><h1>400 Bad Request</h1></center>
debug1: kex_exchange_identification: banner line 11: <hr><center>nginx/1.18.0</center>
debug1: kex_exchange_identification: banner line 12: </body>
debug1: kex_exchange_identification: banner line 13: </html>
kex_exchange_identification: Connection closed by remote host