Hallo, meine Nextcloud Installation (Raspberry Pi, Apache) gibt noch eine weitere Warnung aus:
The "Strict-Transport-Security" HTTP header is not set to at least "15552000" seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips.
Nach einiger Recherche glaube ich folgende Zeilen in der Apache Virtual Host Datei ergänzen zu müssen:
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
Nun habe ich die gesamte SSL Installation mit zwei Certbot Anweisungen erledigt und bin daher mit der Konfiguration leider nicht sonderlich firm. Ich vermute, dass eine der folgenden Dateien die gesuchte Virtual Host Datei ist:
Das ist schon das richtige Verzeichnis. Wirksam sind nur die Einträge in /etc/apache2/sites-enabled. Dies sind symbolische Links zu den gleichnamigen Dateien in sites-available. In den beiden Dateien
solltest du Hinweise auf deine Nextcloud Installation finden. Hier kannst du auch den Header eintragen. Es reicht wohl, den Header in der ssl.conf einzutragen, wenn du den Zugang über https benutzt.
Danke, so sieht meine /etc/apache2/sites-available/000-default-le-ssl.conf Datei aus:
<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 ddns.meine-domain.de
SSLCertificateFile /etc/letsencrypt/live/ddns.meine-domain.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ddns.meine-domain.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
Ich hänge das jetzt einfach mal darunter und starte Apache neu:
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
Das Verzeichnis ist ‘/var/www/html/nextcloud’. Die ‘000-default-le-ssl.conf’ hat wohl Certbot erstellt oder zumindest konfiguriert. Ich habe die ganze SSL Installation mit nur zwei Befehlen durchgeführt:
sudo apt-get install python-certbot-apache
sudo certbot --apache
-> E-Mail Adresse eingeben
-> 'Terms of Service' mit 'A'/Enter bestätigen
-> 'Newsletter' mit 'N'/Enter ablehnen
-> Domain eingeben, z.B. ddns.meine-domain.de
-> HTTP mit '2'/Enter automatisch auf HTTPS umleiten
Die Apache Startseite leite ich mit einer .htaccess Datei um:
sudo touch /var/www/html/.htaccess
sudo nano /var/www/html/.htaccess
-> folgende Zeilen einfügen
# 301 Redirect
RewriteEngine on
RewriteBase /
RewriteRule (.*) /nextcloud/$1 [R=301,L]
-> Anmerkung: In der Apache Konfiguration (/etc/apache2/apache2.conf) muss wohl der Eintrag 'AllowOverride' unter '<Directory /var/www/>' auf 'All' gesetzt sein. (Default: None)
Wie die ‘000-default-le-ssl.conf’ aussehen soll, ist mir leider noch nicht ganz klar, ich sehe mir das nochmal am Abend an. Schöne Grüße!
In die /etc/apache2/apache2.conf trägst du gar nichts ein. Das kommt alles in die vhost Datei, also in
000-default-le-ssl.conf. Dort sollte also stehen:
…
AllowOverride All
Require all granted
… </Directory>
Neben den anderen Einträgen. Dann brauchst du meiner Meinung nach auch nicht die Umleitung in der .htaccess. Ich habe die jedenfalls nicht.
Es wäre auch eine gute Idee, die vhost Datei anders zu benennen, etwa
/etc/apache2/sites-available/nextcloud-ssl.conf
Du willst ja später evtl noch weitere vhosts einrichten.
Vielen Dank! Ich habe die ‘.htaccess’ gelöscht und den Eintrag in der ‘apache2.conf’ wieder von ‘All’ auf ‘None’ zurückgesetzt. Die genannten Ergänzungen habe ich in der ‘000-default-le-ssl.conf’ und ‘000-default.conf’ durchgeführt. Soweit klappt auch alles, nur die Zeilen aus dem Ausgangsposting muss ich erst irgendwo unterbringen ^^
Ja, aber ich verstehe den Syntax nicht, egal wo und wie ich es probiere, es klappt einfach nicht. Die Warnung im Administrator Menü verschwindet nicht bzw. lässt sich der Server bei manchen Varianten nicht mehr neustarten.
Danke, mit ‘sudo a2enmod headers’ hat es endlich geklappt. Hier zur Volsständigkeit noch meine ‘000-default-le-ssl.conf’ Datei:
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/nextcloud
<Directory /var/www/html/nextcloud>
Require all granted
AllowOverride All
</Directory>
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
# 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 ddns.meine-domain.de
SSLCertificateFile /etc/letsencrypt/live/ddns.meine-domain.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/ddns.meine-domain.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>
ich würde gerne das Thema nochmal aufgreifen wollen, da ich auch diesen Fehler habe.
Wenn ich die Datei “000-default-le-ssl.conf” in diesem Verzeichnis “/etc/apache2/sites-enabled/” oder in diesem “/etc/apache2/sites-available/” öffne, dann ist die Datei leer.
Ich bekomme diesen Fehler einfach nicht weg. Hat jemand eine genaue Schritt für Schritt Anleitung?
Existiert die Datei bei dir überhaupt? Evtl. heisst deine Config Datei für Nextcloud ja anders? Ich nutze z.B. die Deafult Dateien gar nicht. Meine Datei heisst nextcloud-le-ssl.conf…