Trotz Reverse Proxy: Connection refused from the non-local address

Begonnen von heikoh81, 06 Dezember 2025, 12:10:43

Vorheriges Thema - Nächstes Thema

heikoh81

Hallo zusammen,

ich habe eine fhem-Instanz (debian, nicht dockerized) auf einem VPS laufen, der auch als Mail-, Web- und VPN-Server bei mir fungiert.
Fhem ist hinter einem Nginx-Reverse-Proxy mit BasicAuth geschaltet:
    location /fhem {
        set $my_http_upgrade "";
        set $my_connection "Connection";
        if ($http_upgrade = "websocket") {
          set $my_http_upgrade $http_upgrade;
          set $my_connection "upgrade";
        }
        proxy_set_header Upgrade $my_http_upgrade;
        proxy_set_header Connection $my_connection;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_read_timeout 2073600;
        proxy_buffering off;
        proxy_pass http://localhost:8083/fhem;
auth_basic "Restricted Content";
auth_basic_user_file /etc/nginx/.htpasswd;
    }

Das funktioniert auch, d.h. bei aufruf der URL kommt eine BasicAuth abfrage.

Da BasicAuth ja nicht mehr so Stand der Technik ist, habe ich vor Monaten einen dockerized NginxProxyManager mit Authelia davor geschaltet, um so eine Art SingleSignOn für meine Applikationen zu haben.
Das funktioniert auch alles, inklusive Fail2Ban usw., und dennoch habe ich das hier im log:

2025.12.06 11:58:40 1: Connection refused from the non-local address 93.174.95.106:59434, as there is no working allowed instance defined for it
2025.12.06 11:58:40 1: Connection refused from the non-local address 93.174.95.106:59460, as there is no working allowed instance defined for it
2025.12.06 11:58:41 1: Connection refused from the non-local address 93.174.95.106:59574, as there is no working allowed instance defined for it
2025.12.06 11:58:41 1: Connection refused from the non-local address 93.174.95.106:59600, as there is no working allowed instance defined for it
2025.12.06 11:58:41 1: Connection refused from the non-local address 93.174.95.106:59658, as there is no working allowed instance defined for it

Ich verstehe überhaupt nicht, wie das überhaupt zu fhem durchkommt. fhem sollte nur port 8083 offen haben, warum reagiert das überhaupt auf die hier gezeigten ports?

define WEB FHEMWEB 8083 global
setuuid WEB 65.......
attr WEB JavaScripts codemirror/fhem_codemirror.js
attr WEB csrfToken none
attr WEB editConfig 1
attr WEB longpoll 1

Ich habe jetzt mal das "global" testweise entfernt & werde das Log beobachten.
Dennoch verstehe ich nicht, wieso fhem überhaupt auf die ganzen Ports lauscht.

Viele Grüße,
Heiko

betateilchen

#1
Diese ports im 50.000er Bereich sind temporäre interne Verbindungen, die von FHEM benötigt werden.
Die sieht man prinzipiell in jedem FHEM, wenn man "list TYPE=FHEMWEB" eingibt:
Diese Verbindungen entstehen und verschwinden von alleine wieder.

Bei mir sieht das aktuell beispielsweise so aus:

web_longpoll
web_longpoll_192.168.123.162_59839
web_longpoll_192.168.123.162_59840
web_longpoll_192.168.123.162_59842
web_longpoll_192.168.123.162_59843
web_longpoll_192.168.123.162_59844
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

heikoh81

#2
Danke für deine schnelle Antwort.
Vorweg: Seit ich in der DEF 8083 global auf nur 8083 geändert habe, gibt es keine solchen Log-Einträge mehr.

Bzgl. der 50000er-Ports:
Ich habe leider auch Zugriffe bei niedrigeren Ports, sieht irgendwie nach Portscans aus:
2025.12.01 00:51:54 1: Connection refused from the non-local address 79.124.49.90:50124, as there is no working allowed instance defined for it
2025.12.01 01:26:29 1: Connection refused from the non-local address 162.142.125.125:1922, as there is no working allowed instance defined for it
2025.12.01 01:26:29 1: Connection refused from the non-local address 162.142.125.125:1942, as there is no working allowed instance defined for it
2025.12.01 01:26:29 1: Connection refused from the non-local address 162.142.125.125:1946, as there is no working allowed instance defined for it
2025.12.01 01:26:29 1: Connection refused from the non-local address 162.142.125.125:1948, as there is no working allowed instance defined for it
2025.12.01 01:26:33 1: Connection refused from the non-local address 162.142.125.125:2038, as there is no working allowed instance defined for it
2025.12.01 01:26:36 1: Connection refused from the non-local address 162.142.125.125:2084, as there is no working allowed instance defined for it
2025.12.01 07:38:02 1: Connection refused from the non-local address 167.94.138.116:8824, as there is no working allowed instance defined for it
2025.12.01 07:38:02 1: Connection refused from the non-local address 167.94.138.116:8834, as there is no working allowed instance defined for it
2025.12.01 07:38:03 1: Connection refused from the non-local address 167.94.138.116:11590, as there is no working allowed instance defined for it
2025.12.01 07:38:03 1: Connection refused from the non-local address 167.94.138.116:11606, as there is no working allowed instance defined for it
2025.12.01 07:38:12 1: Connection refused from the non-local address 167.94.138.116:38262, as there is no working allowed instance defined for it
2025.12.01 10:41:44 1: Connection refused from the non-local address 198.235.24.64:61954, as there is no working allowed instance defined for it
2025.12.01 10:41:45 1: Connection refused from the non-local address 198.235.24.64:61970, as there is no working allowed instance defined for it
2025.12.01 15:59:55 1: Connection refused from the non-local address 203.55.131.4:53802, as there is no working allowed instance defined for it
2025.12.01 16:16:10 1: Connection refused from the non-local address 203.55.131.4:38150, as there is no working allowed instance defined for it
2025.12.01 18:36:11 1: Connection refused from the non-local address 45.135.193.9:46070, as there is no working allowed instance defined for it

Ich habe für einen abgeschlossenen Monat mehr als 1000 solche Zeilen gehabt.

"list TYPE=FHEMWEB" ergibt aktuell (ohne global):
WEB
WEB_127.0.0.1_51772
WEB_127.0.0.1_58006
So ist es ja in Ordnung.

Viele Grüße,
Heiko

Otto123

#3
Hallo Heiko,

da ich dein exaktes Setup nur ahnen kann:
mit global bindet FHEM die 8083 an alle Netzwerkschnittstellen: 0.0.0.0:8083 beantwortet aber eigentlich nur Anfragen aus privaten Netzwerken (siehe help FHEMWEB - allowfrom Attribute, dein Log zeigt: es hat genauso gewirkt  ;) )
ohne global bindet FHEM die 8083 an 127.0.0.1:8083
Die Portbindungen kannst Du Dir z.B. mit ss -lntu anschauen.
Insofern sollten jetzt die Logeinträge in FHEM vom 1.12. Geschichte sein.

Dein Proxy wirkt als Sicherheitsschleuse natürlich nicht für "alles" was an die öffentliche IP gebunden ist. Du solltest also darauf achten, dass nur Port 80 und 443 von deinem Proxy an die öffentliche IP gebunden sind. Alles andere sollte nur intern lauschen, ansonsten sind alle Prozesse die öffentlich lauschen potentiell angreifbar.

Gruß Otto
Viele Grüße aus Leipzig  ⇉  nächster Stammtisch an der Lindennaundorfer Mühle
RaspberryPi B B+ B2 B3 B3+ ZeroW,HMLAN,HMUART,Homematic,Fritz!Box 7590,WRT3200ACS-OpenWrt,Sonos,VU+,Arduino nano,ESP8266,MQTT,Zigbee,deconz