Hallo liebe Leute,
ein nginx Server ist als Reverse Proxy Server vorgeschaltet um SSH und SSL auf einem Port (12345) zu trennen. Der nginx erkennt das Datenübertragungsprotokoll und trennt den Datenverkehr hinter dem Proxy entsprechend auf zwei Ports auf --> SSH wird auf PORT 9999 weitergeleitet und SSL Anfragen auf PORT 8080 (Python-Webserver).
Dazu ist der nginx wie folgt konfiguriert:
/etc/nginx/nginx_conf
[...]
stream {
upstream ssh {
server localhost:9999;
}
upstream https {
server localhost:8080;
}
map $ssl_preread_protocol $upstream {
default ssh;
"" https;
"TLSv1.2" https;
"TLSv1.3" https;
"TLSv1.1" https;
"TLSv1.0" https;
}
# SSH and SSL on the same port
server {
listen 12345;
proxy_pass $upstream;
ssl_preread on;
}
}
[...]
Alles anzeigen
Beim Aufruf des Webservers über http://localhost:12345 wird sauber auf den Port 8080 weitergeleitet und der Zugriff auf den Webserver läuft wunschgemäß ab.
Das Problem liegt beim Versuch eine Verbindung via SSH herzustellen.
Ich kann mich zwar lokal per ssh user@<ip-rpi> -p 9999 auf den Raspberry Pi verbinden - nicht aber über den nginx Port 12345.
Anpassungen in /etc/ssh/sshd_config
Ein Aufruf von ssh user@<ip-rpi> -p 12345 -vvv bringt:
OpenSSH_7.9p1 Raspbian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolve_canonicalize: hostname 192.168.2.198 is address
debug2: ssh_connect_direct
debug1: Connecting to 192.168.2.198 [192.168.2.198] port 12345.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Raspbian-10+deb10u2
debug1: ssh_exchange_identification: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
debug1: ssh_exchange_identification: "http://www.w3.org/TR/html4/strict.dtd">
debug1: ssh_exchange_identification: <html>
debug1: ssh_exchange_identification: <head>
debug1: ssh_exchange_identification: <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
debug1: ssh_exchange_identification: <title>Error response</title>
debug1: ssh_exchange_identification: </head>
debug1: ssh_exchange_identification: <body>
debug1: ssh_exchange_identification: <h1>Error response</h1>
debug1: ssh_exchange_identification: <p>Error code: 400</p>
debug1: ssh_exchange_identification: <p>Message: Bad HTTP/0.9 request type ('SSH-2.0-OpenSSH_7.9p1').</p>
debug1: ssh_exchange_identification: <p>Error code explanation: HTTPStatus.BAD_REQUEST - Bad request syntax or unsupported method.</p>
debug1: ssh_exchange_identification: </body>
debug1: ssh_exchange_identification: </html>
ssh_exchange_identification: Connection closed by remote host
Alles anzeigen
An der Stelle hoffe ich auf euere Hilfe / Ideen zur Lösung meines Problemes.
Vielen Dank an der Stelle und schöne Grüße
opc241