SSL Verbindung zu Fhem mit Letsencrypt

Begonnen von golli, 07 Januar 2017, 18:50:58

Vorheriges Thema - Nächstes Thema

Wernieman

https://httpd.apache.org/docs/2.4/mod/mod_proxy.html

Gibt auch Anleitungen dazu hier im Forum .. must Du suchen.

Sorry, aber mit apache als Proxy kenne ich mich seit 3 Jahren nicht mehr aus. verwende da nur noch den nginx. Gibt aber genug Anleitungen (s.o.).
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

ing.robby

Hab's hinbekommen :)

Folgende Dinge waren notwendig:

im Verzeichnis /etc/apache2/sites-available war die Datei 000-default.conf --> habe ich gelöscht (jetzt gibt es nur noch <domain>.conf)

Da ich auch in meinem Netzwerk intern über https auf fhem zugreife musste ich folgendes in meiner <domain>.conf hinzufügen:


    SSLProxyEngine on
    SSLProxyVerify none
    SSLProxyCheckPeerCN off
    SSLProxyCheckPeerName off
    SSLProxyCheckPeerExpire off


Jetzt klappt der Zugriff vom Web aus.


Was ist der Unterschied zwischen Apache2 und nginx?

Gruß Robby
RasPi 3B+ | Ubuntu Mate 18.04, fhem 5.9
nanoCUL433 | IT1500
nanoCUL868 | CCU2, HM-ES-PMSw1-DR, HM-WS550STH, HmIP-BWTH, HmIP-STHO, HmIP-SMI
JeeLink868 | PCA301
hue Bridge | Single bulb, Lightstrip Plus, LivingColors Iris, ZigBee Smart+

Wernieman

Anderes Programm für die gleiche Aufgabe ...
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

ing.robby

#48
Hallo,

nach einem SD Card Crash musste ich nun leider wieder fhem neu einrichten. Bitte keine Sprüche bzgl. backup ect.  :-[
Nun hänge ich wieder am Thema Apache Reverse mit letsencrypt.

root@RasPi:/opt/letsencrypt# ./letsencrypt-auto certonly --rsa-key-size 4096 -d <damain>
Saving debug log to /var/log/letsencrypt/letsencrypt.log

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Apache Web Server plugin - Beta (apache)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 2
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for <domain>
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. <domain> (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://<domain>/.well-known/acme-challenge/GqjuxV9SY5BxBLwPqzw0zWUG_DdnhQ5SnpkNyhLlG1c: Error getting validation data

IMPORTANT NOTES:
- The following errors were reported by the server:

   Domain: <domain>
   Type:   connection
   Detail: Fetching
   http://<domain>/.well-known/acme-challenge/GqjuxV9SY5BxBLwPqzw0zWUG_DdnhQ5SnpkNyhLlG1c:
   Error getting validation data

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.


Ich habe schon unzählige Foren nach dem Fehler durchsucht, aber noch keine Lösung gefunden. Kann mir jemand helfen?

<domain> entspricht meiner Domain

Gruß Robby
RasPi 3B+ | Ubuntu Mate 18.04, fhem 5.9
nanoCUL433 | IT1500
nanoCUL868 | CCU2, HM-ES-PMSw1-DR, HM-WS550STH, HmIP-BWTH, HmIP-STHO, HmIP-SMI
JeeLink868 | PCA301
hue Bridge | Single bulb, Lightstrip Plus, LivingColors Iris, ZigBee Smart+

Wernieman

1. Wenn Du "Stand Allone" wählst, darf KEIN anderer Webserver laufen
2. Ist Deine Domain auch wirklich die Richtige IP?
3. ist http, also Port 80 aus dem Web erreichbar?

Würde Dir allerdings besser Raten, es mit 3 "Place files in webroot directory (webroot)" zu machen. Das ist Browser unabhängiger und kann ohne den Webserver runterzufahren, laufen. Alternativ die 1.... habe aber prsöhnlich schon mal Probleme damit gehabt ...
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

ing.robby

Hallo Wernieman,

ich habe es jetzt mit nginx versucht. Der Zugriff aus dem Internet funktioniert, aber wenn ich letsencrypt nutzen will, kommt der gleiche Fehler wie bei apache.

Befehl:
./letsencrypt-auto certonly -a standalone -d <domain>

Fehler:
root@RasPi:/opt/letsencrypt# ./letsencrypt-auto certonly -a standalone -d <domain>
Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for <domain>
Waiting for verification...
Cleaning up challenges
Failed authorization procedure. <domain> (http-01): urn:ietf:params:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://<domain>/.well-known/acme-challenge/WVokj-9aMOW4jKU7nGxw68DymqPVkK9zQi7Zj-afNFU: Error getting validation data

IMPORTANT NOTES:
- The following errors were reported by the server:

   Domain: <domain>
   Type:   connection
   Detail: Fetching
   http://<domain>/.well-known/acme-challenge/WVokj-9aMOW4jKU7nGxw68DymqPVkK9zQi7Zj-afNFU:
   Error getting validation data

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.


Hängt das vielleicht damit zusammen, dass "http" steht, anstatt "https"?

Gruß Robby
RasPi 3B+ | Ubuntu Mate 18.04, fhem 5.9
nanoCUL433 | IT1500
nanoCUL868 | CCU2, HM-ES-PMSw1-DR, HM-WS550STH, HmIP-BWTH, HmIP-STHO, HmIP-SMI
JeeLink868 | PCA301
hue Bridge | Single bulb, Lightstrip Plus, LivingColors Iris, ZigBee Smart+

Wernieman

1. Wenn Du "standalone" nutzen willst, darf apache oder nginx NICHT laufen

Siehe mein Beitrag! Bitte LESEN

Bevor wir jetzt weiterreden erstmal die Frage: Ist Dein nginx über http extern erreichbar?
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

ing.robby

Hallo Wernieman,

ich habe deinen Beitrag gelesen. Apache und nginx liefen nicht während letsencrypt Installation.
Nein nginx ist nicht über http erreichbar, sondern über https, so ist es ja auch gewollt.

Gruß Robby
RasPi 3B+ | Ubuntu Mate 18.04, fhem 5.9
nanoCUL433 | IT1500
nanoCUL868 | CCU2, HM-ES-PMSw1-DR, HM-WS550STH, HmIP-BWTH, HmIP-STHO, HmIP-SMI
JeeLink868 | PCA301
hue Bridge | Single bulb, Lightstrip Plus, LivingColors Iris, ZigBee Smart+

Wernieman

d.h. extern ist die Maschine, auf der letsencrypt läuft, NICHT über http erreichbar? Damit wird es dann wohl nichts mit letsencrypt .... denn das braucht für die Erstinstallation http ....

btw: Schau mal, was alles auf port 80 hört:
netstat -lntp | grep 80
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

ing.robby

Letsencrypt läuft nicht. Scheitert ja bei der Installation.
Und meine Subdomain für fhem ist nicht unter http erreichbar.

netstat -lntp | grep 80
liefert:
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      28805/nginx: master
tcp        0      0 0.0.0.0:8083            0.0.0.0:*               LISTEN      28969/perl
tcp        0      0 0.0.0.0:8084            0.0.0.0:*               LISTEN      28969/perl
tcp        0      0 0.0.0.0:8085            0.0.0.0:*               LISTEN      28969/perl
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      28805/nginx: master


Gruß Robby
RasPi 3B+ | Ubuntu Mate 18.04, fhem 5.9
nanoCUL433 | IT1500
nanoCUL868 | CCU2, HM-ES-PMSw1-DR, HM-WS550STH, HmIP-BWTH, HmIP-STHO, HmIP-SMI
JeeLink868 | PCA301
hue Bridge | Single bulb, Lightstrip Plus, LivingColors Iris, ZigBee Smart+

Wernieman

1. laut Deiner Ausgabe ist letsencrypt installiert
2. Deine subdomain für FHEM muß extern über http erreichbar sein .. allerdings geht es auch unter eine Dummy.

Habe bei mir im nginx einfach folgenden Eintrag drinnen:
server {
    listen      80 default_server;
    listen      [::]:80 default_server;
    server_name default_server;

    root /usr/share/nginx/html;
    index index.html index.htm;

    access_log  /var/log/nginx/default.access.log;
    error_log   /var/log/nginx/default.error.log;

    # Sicherheit
    server_tokens off;
    add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains' always;

    # Für LetsEncrypt
    location ~ /\.well-known {
        root /usr/share/nginx/html;
    }

    # Alles andere auf https://
    location / {
        try_files $uri $uri/ =404;
        return 301 https://$host$request_uri;
    }
}


Dann kannst Du ein Zertifikat erstellen (nginx muß laufen!)
letsencrypt certonly  --webroot -w /usr/share/nginx/html -d Domain1 -d Domain2 ....

Allerdings ist der Aufruf aus dem Kopf geschrieben (und man-Pages), nicht getestet. Das kann ich Dir erst morgen geben.

Dieses hat den Vorteil, das Du auch bei einem laufendem nginx ein "letsencrypt renew" machen kannst.
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

ing.robby

Ja du hast Recht, installiert ist letsencrypt. Erst bei dem Befehl
./letsencrypt-auto certonly --rsa-key-size 4096 -d <domain>
Kommt die beschriebene Fehlermeldung.

letsencrypt certonly  --webroot -w /usr/share/nginx/html -d <domain>
Funktioniert auch nicht.
Ausgabe:
Failed authorization procedure. <domain> (http-01): urn:acme:error:connection :: The server could not connect to the client to verify the domain :: Fetching http://<domain>/.well-known/acme-challenge/C0gOuxY98vY1zcZGQyC3dRSZQ7JRL4V9z8L6QzC1XFc: Error getting validation data

IMPORTANT NOTES:
- The following errors were reported by the server:

   Domain: <domain>
   Type:   connection
   Detail: Fetching
   http://<domain>/.well-known/acme-challenge/C0gOuxY98vY1zcZGQyC3dRSZQ7JRL4V9z8L6QzC1XFc:
   Error getting validation data

   To fix these errors, please make sure that your domain name was
   entered correctly and the DNS A/AAAA record(s) for that domain
   contain(s) the right IP address. Additionally, please check that
   your computer has a publicly routable IP address and that no
   firewalls are preventing the server from communicating with the
   client. If you're using the webroot plugin, you should also verify
   that you are serving files from the webroot path you provided.
- Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.


RasPi 3B+ | Ubuntu Mate 18.04, fhem 5.9
nanoCUL433 | IT1500
nanoCUL868 | CCU2, HM-ES-PMSw1-DR, HM-WS550STH, HmIP-BWTH, HmIP-STHO, HmIP-SMI
JeeLink868 | PCA301
hue Bridge | Single bulb, Lightstrip Plus, LivingColors Iris, ZigBee Smart+

Wernieman

Prüfe erstmal, ob Deine Domain auch extern erreichbar ist (http!!)
Dann ... können wir weitermachen.

Siehe Ausgabe:
The server could not connect to the client to verify the domain :: Fetching http://<domain>/.well-known/acme-challenge/C0gOuxY98vY1zcZGQyC3dRSZQ7JRL4V9z8L6QzC1XFc:
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html

ing.robby

Nein ist sie nicht. Ist nur über https erreichbar, hatte ich schon geschrieben.
Verstehe auch nicht, warum sie über http erreichbar sein soll. Will ja verwchlüsselt darauf zugreifen...

Oder ist das für die Einrichtung von letsencrypt erforderlich? Und ich stelle das später um?
RasPi 3B+ | Ubuntu Mate 18.04, fhem 5.9
nanoCUL433 | IT1500
nanoCUL868 | CCU2, HM-ES-PMSw1-DR, HM-WS550STH, HmIP-BWTH, HmIP-STHO, HmIP-SMI
JeeLink868 | PCA301
hue Bridge | Single bulb, Lightstrip Plus, LivingColors Iris, ZigBee Smart+

Wernieman

#59
Für https brauchst Du ein Zertifikat, was Du nicht hast. Um eines aufzubauen, willst Du aber über https gehen, wofür Du kein Zertiikat hast, da Du kein https ...... Es ist ein Henne Ei Problem!

Also ... ohne http geht es nicht.

Punkt (s.o. und lets-Ecnrypt-Doku)

Und wie Du es umstellst, siehe mein nginx-Auszug.

Und fürs dauerhafte würde ich Dir auch empfehlen, http laufen zu lassen. Letsencrypt-zertifikate haben eine Lebensdauer von 3 Monaten. Man kann Sie aber automatisch verlängern lassen (letsencrypt renew).

Also mal in Steps:
1. http Einrichten!
2. Externe Erreichbarkeit von http prüfen
3. letsencrypt laufen lassen
4. nginx mit https erweitern
5. externe Erreichbarkeit von htps prüfen
6. Sich freuen!

Sorry aber das sind Basics. Bitte lesedir mal die Letsencrypt Doku durch! Und das mit http habe ich schon 3? mal geschrieben ....
- Bitte um Input für Output
- When there is a Shell, there is a Way
- Wann war Dein letztes Backup?

Wie man Fragen stellt: https://tty1.net/smart-questions_de.html