HTTP Header "Fehler" verschwindet nicht

Hallo zusammen,

meine Nextcloud vermeldet:

  • 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 :arrow_upper_right:.

meine

nano /etc/apache2/sites-available/nextcloud.conf 

sagt aber

<VirtualHost *:80>
     ServerAdmin mail***address***.com
     DocumentRoot /var/www/nextcloud/
     ServerName ****.**
     Redirect permanent / https://***.**
     Alias /nextcloud "/var/www/nextcloud/"

     <Directory /var/www/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
     </Directory>

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

RewriteEngine on
RewriteCond %{SERVER_NAME} =***.**
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

</VirtualHost>

<VirtualHost *:443>
  ServerName ***.**
    <IfModule mod_headers.c>
      Header always set Strict-Transport-Security "max-age=15768000; includeSubDomains; preload"
    </IfModule>
 </VirtualHost>

sieht doch an sich gut aus, oder übersehe ich etwas?

Der Server läuft bei einem Dienstleister von uns, ist virtuell & root ist vorhanden.
System ist Debian 11, Maria DB & NC Hub II (23.0.0)

Huhu, ist denn mod_headers bei dir installiert und geladen?

Was sagt die .htaccess in www/Nextcloud ?

Hi,
komme erst jetzt zum Antworten… Ja sieht so aus:

sudo a2enmod headers
Module headers already enabled

ziemlich viel… leider nichts was mir was sagt…

<IfModule mod_headers.c>
  <IfModule mod_setenvif.c>
    <IfModule mod_fcgid.c>
       SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
       RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
    <IfModule mod_proxy_fcgi.c>
       SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
    </IfModule>
    <IfModule mod_lsapi.c>
      SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
      RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
    </IfModule>
  </IfModule>

  <IfModule mod_env.c>
    # Add security and privacy related headers

    # Avoid doubled headers by unsetting headers in "onsuccess" table,
    # then add headers to "always" table: https://github.com/nextcloud/server/pull/19002
    Header onsuccess unset Referrer-Policy
    Header always set Referrer-Policy "no-referrer"

    Header onsuccess unset X-Content-Type-Options
    Header always set X-Content-Type-Options "nosniff"

    Header onsuccess unset X-Download-Options
    Header always set X-Download-Options "noopen"

    Header onsuccess unset X-Frame-Options
    Header always set X-Frame-Options "SAMEORIGIN"

    Header onsuccess unset X-Permitted-Cross-Domain-Policies
    Header always set X-Permitted-Cross-Domain-Policies "none"

    Header onsuccess unset X-Robots-Tag
    Header always set X-Robots-Tag "none"

    Header onsuccess unset X-XSS-Protection
    Header always set X-XSS-Protection "1; mode=block"

    SetEnv modHeadersAvailable true
  </IfModule>

  # Add cache control for static resources
  <FilesMatch "\.(css|js|svg|gif|png|jpg|ico|wasm|tflite)$">
    Header set Cache-Control "max-age=15778463"
  </FilesMatch>

  # Let browsers cache WOFF files for a week
  <FilesMatch "\.woff2?$">
    Header set Cache-Control "max-age=604800"
  </FilesMatch>
</IfModule>

# PHP 7.x
<IfModule mod_php7.c>
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>

# PHP 8+
<IfModule mod_php.c>
  php_value mbstring.func_overload 0
  php_value default_charset 'UTF-8'
  php_value output_buffering 0
  <IfModule mod_env.c>
    SetEnv htaccessWorking true
  </IfModule>
</IfModule>

<IfModule mod_mime.c>
  AddType image/svg+xml svg svgz
  AddType application/wasm wasm
  AddEncoding gzip svgz
</IfModule>

<IfModule mod_dir.c>
  DirectoryIndex index.php index.html
</IfModule>

<IfModule pagespeed_module>
  ModPagespeed Off
</IfModule>

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{HTTP_USER_AGENT} DavClnt
  RewriteRule ^$ /remote.php/webdav/ [L,R=302]
  RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
  RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
  RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
  RewriteRule ^remote/(.*) remote.php [QSA,L]
  RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
  RewriteRule ^\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
  RewriteRule ^(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]
</IfModule>

AddDefaultCharset utf-8
Options -Indexes
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 //
dErrorDocument 404 //

Und genau da liegt der Denkfehler. sites-available

Die was Aktiv ist ist immer in sites-enabled
/etc/apache2/sites-enabled

Außer es rennt noch ein Include irgendwohin drauf.

ja danke :smiley:
aber ich hab geschaut, unter sites-enabled steht das gleiche…

Grundsätzlich schon, aber häufig (bzw. immer, ich kenne es jedenfalls nur so) wird da mit einem Link gearbeitet:

Vielleicht könntest du erst mal schauen, ob der Header überhaupt gesendet wird, z.B. mit curl -v https://deinedomain, dort sollte dann etwas in der Richtung strict-transport-security: max-age=15552000; includeSubDomains auftauchen.
Der Apache hängt ansonsten direkt im Netz, oder ist da noch ein Reverse Proxy o.ä. vor?

1 Like

Ist das ein Fehler vom kopieren oder steht dort das “d” for “ErrorDocument” ?

Ich hab in den Jahrzehnten schon so manchen Schmarn gesehen…
Grundsätzlich gibt es bei mir nicht mehr :wink:

Aber curl -v ist schon mal gut zum schauen ob die Module was raushauen.

Vorausgesetzt das ist überhaupt installiert :wink:

Es könnte aber auch ein Weiterleitungsfehler sein.
Von http:// auf https://

schau mal auf https://www.redirect-checker.org/

Und man sollte mal checken was du überhaupt Installiert hast.
sudo dpkg -l nginx
sudo dpkg -l apache2

copy paste fehler von mir…

ich habe wohl 301 und 302 aktiv… wie? gute Frage :smiley: Da muss ich mal schauen.

sudo dpkg -l nginx
dpkg-query: no packages found matching nginx

sudo dpkg -l apache2
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version          Architecture Description
+++-==============-================-============-=================================
ii  apache2        2.4.52-1~deb11u2 amd64        Apache HTTP Server