Hauptmenü

Beta-Test

Begonnen von Syrex-o, 16 April 2020, 20:12:22

Vorheriges Thema - Nächstes Thema

kabanett

Hallo,
ich habe die Beta installiert und die Verbindung usw klappt sofort.
Die Bedienung ist echt induitiv!
Ich habe mir, zum Test, eine Lampe angelegt. Funtioniert soweit. Leider wird mir der fhem- Name angezeigt. Ich kann zwar den Schalter Label schalten, aber es gibt keine Möglichkeit einen normal lesbaren Namen zu vergeben.

Die Theme- Einstellung dark oder bright ergibt bei mir keinen Unterschied...

Gruß
Hardware: Fhem auf Raspi3 / selbtsbau CUL 433 und 868 MHz / MAX Thermostate / IT-Dosen nur noch Weihnachten / diverse ESP Aktoren/Sensoren / X10 Fernbedienung / Shelly 1, 1L, 2, 2.5, Dimmer, RGB2 / LaCrosseGateway / Zigbee2531 / diverse Zigbee Aktoren/Sensoren

Syrex-o

Zitat von: kabanett am 08 März 2023, 17:22:42
Hallo,
ich habe die Beta installiert und die Verbindung usw klappt sofort.
Die Bedienung ist echt induitiv!
Ich habe mir, zum Test, eine Lampe angelegt. Funtioniert soweit. Leider wird mir der fhem- Name angezeigt. Ich kann zwar den Schalter Label schalten, aber es gibt keine Möglichkeit einen normal lesbaren Namen zu vergeben.

Die Theme- Einstellung dark oder bright ergibt bei mir keinen Unterschied...

Gruß
Vielen Dank für das Feedback.

Der Switch hat die Option "Eigene Labels". Dann kannst du ein Label und auch einen Info Text eingeben.

Mit dem Theme hast du recht. Aktuell gibt es noch kein light Theme.

kabanett

Oh man, hast recht.
War jetzt nicht ganz so induitiv... Ich hab damit gerechnet, dass beim einschalten der Option, die Eingabemöglichkeit auch dort (oder zumindest in der Nähe) erscheint/befindet und nicht weiter hoch gescrollt werden muss.

Gruß
Hardware: Fhem auf Raspi3 / selbtsbau CUL 433 und 868 MHz / MAX Thermostate / IT-Dosen nur noch Weihnachten / diverse ESP Aktoren/Sensoren / X10 Fernbedienung / Shelly 1, 1L, 2, 2.5, Dimmer, RGB2 / LaCrosseGateway / Zigbee2531 / diverse Zigbee Aktoren/Sensoren

Syrex-o

#63
Zitat von: Tueftler1983 am 08 März 2023, 14:10:54
scheint immer noch das selbe zu sein,


main.675b46775ba190f9.js:1 WebSocket connection to 'wss://XXXXX:xxxxx@XXXXX.zapto.org/?XHR=1&inform=type=status;filter=.*;fmt=JSON&timestamp=1678280898822' failed:
main.675b46775ba190f9.js:1 WebSocket connection to 'wss://XXXXX:xxxxx@192.168.2.172/?XHR=1&inform=type=status;filter=.*;fmt=JSON&timestamp=1678280911522' failed:


extern erreiche ich fhem so im Browser
xxx-xxx.zapto.org/fhem
intern 192.168.2.172/fhem

Also um extern auf fhem zuzugreifen, hast du ein den prefix "https://" richtig?
Intern dann nur noch "http://" oder direkt die IP?

In deinem test schlagen ja beide Methoden fehl.

Lösung:
Ich habe einen Fehler in meinem Connection handler gefunden + Fehler in der Apache conf.

Ich habe jetzt mal genau das Tutorial von dir genommen und einen Apache2 Server vor mein FHEM geschaltet.
Die Methode mit dem SSL Zertifikat funktioniert so leider nicht mehr. Daher habe ich mir eins mit openssl angelegt.
Dabei sind mir ein paar Dinge aufgefallen. Daher hier mal meine Schritte, damit es funktioniert.

1. Relevante module aktivieren: sudo a2enmod proxy proxy_http proxy_wstunnel rewrite ssl
2. Die Apache Config: /etc/apache2/conf-available/fhem.conf

<IfModule mod_proxy.c>
  <Location /fhem>
    RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /(.*)           ws://localhost:8083/fhem$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /(.*)           http://localhost:8083/fhem$1 [P,L]

    ProxyPass http://localhost:8083/fhem
    ProxyPassReverse http://localhost:8083/fhem

  </Location>
</IfModule>

Bitte unbedingt auf die Ports achten.

Ich habe auch die Konfiguration mit: ws://localhost:8083/fhem/$1 ausprobiert. Klappt auch.

FhemNative Änderungen
In FhemNative wurde bisher immer erwartet, dass es einen Port gibt  ::). Mein Fehler.

Mit deiner Anleitung und folgenden IP Einstellungen konnte ich mich "insecure/secure" verbinden. Nur lokal getestet.

IP: "Deine FHEM IP"/fhem (Bsp. 192.168.178.141/fhem)
PORT: einfach alles raus löschen
Verbindungstyp: fhemweb
Sichere Verbindung: An oder aus -> geht beides in meinen Tests.


Ich kommentiere diesen Post erneut, wenn ich die Alpha mit den Fixes hochgeladen habe.

Edit:
Alpha v3 ist auf Github verfügbar: https://github.com/Syrex-o/FhemNative/releases/tag/v4.0.0-alpha-3

Tueftler1983

#64
Hey ich teste gleich wenn ich Zuhause bin,

Die Module sind alle aktiv
pi@FhemServer:~ $ sudo a2enmod proxy proxy_http proxy_wstunnel rewrite ssl
Module proxy already enabled
Considering dependency proxy for proxy_http:
Module proxy already enabled
Module proxy_http already enabled
Considering dependency proxy for proxy_wstunnel:
Module proxy already enabled
Module proxy_wstunnel already enabled
Module rewrite already enabled
Considering dependency setenvif for ssl:
Module setenvif already enabled
Considering dependency mime for ssl:
Module mime already enabled
Considering dependency socache_shmcb for ssl:
Module socache_shmcb already enabled
Module ssl already enabled
pi@FhemServer:~ $


Im Browser brauche ich nur meinen Hostnamen eingeben von unterwegs sprich
hxxxxx.hxxxx.zapto.org/fhem

Ich brauche kein Http oder https schreiben da anfragen die auf Port 80 und 443 bei meiner Fritzbox von aussen ankommen an meinen Fhemserver weitergeleitet werden.

Aber das /fhem ist noch wichtig da man sonst nur auf den apacheServer kommt.

Editiere sobald ich am Laptop Testen konnte

EDIT:

Leider kein erfolg und mit deiner Config funktioniert auch der Browser zugriff auf FHEM nicht mehr richtig, die dahrstellung passt nicht.

bei dir fehlt hier das fhem nach dem/

<IfModule mod_proxy.c>
  <Location /fhem>
    RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /fhem(.*)           ws://localhost:8083/fhem$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /fhem(.*)           http://localhost:8083/fhem$1 [P,L]

    ProxyPass http://localhost:8083/fhem
    ProxyPassReverse http://localhost:8083/fhem

  </Location>
</IfModule>

Syrex-o

Zitat
Leider kein erfolg und mit deiner Config funktioniert auch der Browser zugriff auf FHEM nicht mehr richtig, die dahrstellung passt nicht.

Mein Fehler. Ich hatte mir die FHEM Oberfläche garnicht mehr angeguckt danach. Das ist dann die richtige Config:

<IfModule mod_proxy.c>
  <Location /fhem>
    RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /fhem(.*)           ws://localhost:8083/fhem$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /fhem(.*)           http://localhost:8083/fhem$1 [P,L]

    ProxyPass http://localhost:8083/fhem
    ProxyPassReverse http://localhost:8083/fhem

  </Location>
</IfModule>


Dann muss es ein Problem mit dem Zertifikate geben.
Wie sieht denn deine /etc/apache2/sites-enabled/000-default.conf aus?
Meine als Beispiel:

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        SSLEngine on
        SSLCertificateFile /etc/apache2/certificate/apache-certificate.crt
        SSLCertificateKeyFile /etc/apache2/certificate/apache.key
</VirtualHost>

Tueftler1983

#66
Hey bin zwar unterwegs aberdas ist meine Datei

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =***-***.zapto.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Syrex-o

#67
Zitat von: Tueftler1983 am 09 März 2023, 15:07:25
Hey bin zwar unterwegs aberdas ist meine Datei

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
RewriteEngine on
RewriteCond %{SERVER_NAME} =***-***.zapto.org
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet


Jetzt haben wir doch endlich was gefunden  ;D

Dir fehlt der komplette SSL Eintrag. Wenn Anfragen über HTTPS kommen, landen die bei VirtualHost 443.
Aktuell ersetzt du alle Anfragen egal ob http oder https mit https

Ich sehe auch gar keine Definition für ein SSL Zertifikat?
Wo liegen denn deine Zertifikat und KeyFile? Dann können wir versuchen die aktuellen Zertifikate einzubinden. Ansonsten kann ich auch kurz beschreiben, wie du ein neues erstellen kannst mit openssl.


Tueftler1983

#68
Zitat von: Syrex-o am 09 März 2023, 15:38:03
Jetzt haben wir doch endlich was gefunden  ;D

Dir fehlt der komplette SSL Eintrag. Wenn Anfragen über HTTPS kommen, landen die bei VirtualHost 443.
Aktuell ersetzt du alle Anfragen egal ob http oder https mit https

Ich sehe auch gar keine Definition für ein SSL Zertifikat?
Wo liegen denn deine Zertifikat und KeyFile? Dann können wir versuchen die aktuellen Zertifikate einzubinden. Ansonsten kann ich auch kurz beschreiben, wie du ein neues erstellen kannst mit openssl.

Du da fragst du mich was aber in sofern hast du recht ob ich neinen alias mit Http oder Https aufrufe ist egal er wird immer auf die verschlüsselte interne verschlüsselung umgeleitet.
dies finde ich aber auch okay und kann so bleiben.
wo meine zerfitikate und keys liegen kann ich dir jetzt garnicht sagen... das ist schon so lange her.
aber das sollte das verzeichnes sein:
/etc/letsencrypt/live/xxxx-xxxx.zapto.org

was ich nicht verstehe, die verschlüsselung mit dem gültigen Zerfitikat funktioniert ja, wie kann die config da dann nicht stimmen??

kann ja von jedem Gerät verschlüsselt über xxx-xxx.zapto.org/fhem auf mein Fhem zugreifen.

Syrex-o

Zitat
kann ja von jedem Gerät verschlüsselt über xxx-xxx.zapto.org/fhem auf mein Fhem zugreifen.
Spannend wäre, ob du per Https, http oder keinem prefix darauf zugreift. Über HTTPS sollte es eigentlich nicht gehen.
Wenn du die URL im Browser öffnest, wird das Zertifikat dann als gültig erkannt?

Kannst du nicht einfach einen weiteren VirtualHost mit 443 anlegen und testen ob das geht ?

Ich richte morgen Mal Dyndns bei mir ein und gucke, wie das klappt.

Tueftler1983

#70
Also ich kann
Xxx-xxx.zapto.org/fhem eingeben
Oder
Http://Xxx-xxx.zapto.org/fhem
Oder
Https://Xxx-xxx.zapto.org/fhem

Alle drei Varianten landen auf
Https://Xxx-xxx.zapto.org/fhem

Zertifikat ist gültig und wird erkannt. Siehe Screenshot


Wenn ich mich intern auf fhem verbinde kommt die Meldung das die Verbindung eventuell unsicher ist da es für xxx-xxx.zapto.org und nicht für 192.168.2.172 ausgestellt ist

Syrex-o

Ok, also ich habe jetzt auch mal den DynDNS Prozess durchgemacht und es funktioniert auf anhieb.

Step by Step:
1. weiteres WEB device in FHEM angelegt unter port 8088


2. allowed device in FHEM angelegt mit den Attributen:
- validFor "dein neues WEB device"
- basicAuth "dein base64 hash"

2a Falls unklar ist, wie man den hast erzeugt:

echo -n benutzername:passwort | base64


3. DynDNS:
- Ich habe mir schnell eine Adresse bei dynv6.com angelegt.
- In der Fritzbox das ganze unter DynDNS aktiviert.
- In der Fritzbox die Port Weiterleitung auf 8088 für den FHEM webserver eingerichtet: Ich habe nur Anfragen an den FHEM server mit HTTPS (port 443) erlaubt.

4. openssl Zertifikat anlegen:
- Apache stoppen:

sudo service apache2 stop


- openssl installieren:
apt-get install openssl

- sudo nano /etc/apache2/apache2.conf

- Folgendes eintragen am Ende der Datei:

<Directory /var/www/html>
AllowOverride All
</Directory>


- Zertifikat erzeugen und den Anweisungen folgen:

mkdir /etc/apache2/certificate
cd /etc/apache2/certificate
sudo openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out apache-certificate.crt -keyout apache.key


- Die default apache conf bearbeiten:

sudo nano /etc/apache2/sites-enabled/000-default.conf


- So sieht sie dann aus (alle http Anfragen werden automatisch auf https weitergeleitet):

<VirtualHost *:80>
        RewriteEngine On
        RewriteCond %{HTTPS} !=on
        RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
</VirtualHost>
<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLEngine on
        SSLCertificateFile /etc/apache2/certificate/apache-certificate.crt
        SSLCertificateKeyFile /etc/apache2/certificate/apache.key
</VirtualHost>


- Apache fhem config erstellen:

sudo nano /etc/apache2/conf-available/fhem.conf


IfModule mod_proxy.c>
  <Location /fhem>
    RewriteEngine On

    RewriteCond %{HTTP:Upgrade} =websocket [NC]
    RewriteRule /fhem(.*)           ws://localhost:8088/fhem$1 [P,L]
    RewriteCond %{HTTP:Upgrade} !=websocket [NC]
    RewriteRule /fhem(.*)           http://localhost:8088/fhem$1 [P,L]

    ProxyPass http://localhost:8088/fhem
    ProxyPassReverse http://localhost:8088/fhem

  </Location>
</IfModule>


- Apache starten:

sudo service apache2 start


5. FhemNative Zugangsdaten anpassen:
- die Externe Adresse angeben mit /fhem am Ende
- den Port löschen
- SSL aktivieren
- Basic Auth aktivieren und user und pass eingeben
- Verbindung testen

!!! In dieser Beschreibung geht es nicht um die Sicherheitsaspekte. Das ganze ist nur ein schneller Guide zum testen. !!!

Syrex-o

@Tueftler1983
Ich habe deinen und meinen Beitrag mal bearbeitet. Deine URL war im Klartext angegeben  :-X

Kannst du bitte versuchen deine /etc/apache2/sites-enabled/000-default.conf zu bearbeiten, wie im Beitrag definiert?

Tueftler1983

Hey.
Sorry habe nicht gesehen ich habe noch eine zweite 000-default.conf in etc/apache2/sites-enabled.

die 00-default-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf


ServerName xxxx-xxxx.zapto.org
SSLCertificateFile /etc/letsencrypt/live/xxxx-xxxx.zapto.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxx-xxxx.zapto.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>


danach hast du wahrscheinlich gesucht in der ersten conf oder? der untere abschnitt mit angabe wo das Zerfitikat ist etc

Syrex-o

Zitat von: Tueftler1983 am 10 März 2023, 15:44:17
Hey.
Sorry habe nicht gesehen ich habe noch eine zweite 000-default.conf in etc/apache2/sites-enabled.

die 00-default-le-ssl.conf

<IfModule mod_ssl.c>
<VirtualHost *:443>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf


ServerName xxxx-xxxx.zapto.org
SSLCertificateFile /etc/letsencrypt/live/xxxx-xxxx.zapto.org/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/xxxx-xxxx.zapto.org/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>


danach hast du wahrscheinlich gesucht in der ersten conf oder? der untere abschnitt mit angabe wo das Zerfitikat ist etc

Hey, genau die hab ich gesucht ;)
Alles andere hätte mich auch gewundert.

Könntest du schon die Config testen ?
Bei dir dann halt Anpassungen in beiden configs ;)