Welcome! Log In Create A New Profile

Advanced

NGINX Reverse Proxy SSL+SSH ssh_exchange_identification: Connection closed by remote host

Posted by Request0077 
Hallo zusammen,

Da ich bereits in anderen Foren keinen Erfolg hatte, versuche ich es nun mal direkt bei euch im nginx Forum.

Ein Nginx-Server ist als Reverse-Proxy-Server vorgeschaltet, um SSH und SSL an einem Port (12345) zu trennen. Der Nginx erkennt das Datenübertragungsprotokoll und trennt den Datenverkehr hinter dem Proxy entsprechend an zwei Ports -> SSH wird an PORT 9999 und SSL-Anforderungen an PORT 8080 (Python-Webserver) weitergeleitet.

Der Nginx ist 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;
}
}

[...]



Wenn der Webserver über http://rpi_ip:12345 aufgerufen wird, wird Port 8080 sauber weitergeleitet und der Zugriff auf den Webserver wird wie angefordert ausgeführt.

Das Problem besteht darin, eine Verbindung über SSH herzustellen.

Ich kann lokal eine Verbindung zum Raspberry Pi über ssh user @ ip-rpi -p 9999 herstellen, jedoch nicht über den nginx-Port 12345.

Anpassungen in /etc/ssh/sshd_config:

[...]

Port 9999
AddressFamily any
ListenAddress 0.0.0.0
#ListenAddress ::

[...]



Ein Aufruf an 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



An dieser Stelle hoffe ich auf Ihre Hilfe / Ideen, um mein Problem zu lösen.

LG
Request0077



Edited 1 time(s). Last edit at 11/01/2020 09:57AM by Request0077.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 67
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready