Unable to change Strict-Transport-Security settings
Hello,
this is my very first use of nextcloud, apache, mysql etc, so don't blame me for my n00b questions.
In Settings - Overview I have this error message:
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 ↗.
So I checked the support site.
Redirect all unencrypted traffic to HTTPS
To redirect all HTTP traffic to HTTPS administrators are encouraged to issue a permanent redirect using the 301 status code. When using Apache this can be achieved by a setting such as the following in the Apache VirtualHosts configuration:
<VirtualHost *:80> ServerName cloud.nextcloud.com Redirect permanent / https://cloud.nextcloud.com/ Enable HTTP Strict Transport Security
While redirecting all traffic to HTTPS is good, it may not completely prevent man-in-the-middle attacks. Thus administrators are encouraged to set the HTTP Strict Transport Security header, which instructs browsers to not allow any connection to the Nextcloud instance using HTTP, and it attempts to prevent site visitors from bypassing invalid certificate warnings.
This can be achieved by setting the following settings within the Apache VirtualHost file:
<VirtualHost *:443>
ServerName cloud.nextcloud.com
I went to the folder: /etc/apache2/sites-available/ opened my nextcloud.conf file and this is how it looks like:
Alias /nextcloud "/var/www/nextcloud/"
<Directory /var/www/nextcloud/> Options +FollowSymlinks AllowOverride All
SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud
( it does not make any difference it I put the row with "; preload" directly after includeSubDomains or after the "...)
Can someone put me in the right direction? Trying to solve that issue for several hours now with no success :-(
PS: I am using:
Nextcloud
Version: 15.0.8.1 Apps installed: 34 Apps updates available: 0 PHP
Version: 7.3.5 Memory Limit: 512 MB Max Execution Time: 3600 Upload max size: 511 MB Database
Type: mysql Version: 10.1.38 Size: 2.4 MB
I recommend to remove "preload" for now. Please read https://hstspreload.org/ first.
Apart from that I cannot really see a description of your problem. What ist going wrong? Are you sure that your nextcloud.conf file contains the SSL VirtualHost (Port 443)? Also I cannot see where your Directory directive ends in your post (Where is </Directory>?).
You shouldn't remove the preload. If you do hstspreload returns:
Error: No preload directiveThe header must contain the preload directive.
Also this error is wrong. I have the following and hstspreload like it. Besides the age I'm using is much longer (31,536,000 vs 15,552,000). Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" env=HTTPS
@ugokanain For nextcloud it does not matter if you use preload or not. There is a check to ensure that the header is present and max-age is at least 15552000.
Please use https://help.nextcloud.com for such question. If the check is not working for some reason (e.g. header is present but nextcloud shows a warning to you) feel free to create a new report with the issue template and include curl -I https://cloud.nextcloud.com | grep "Strict-Transport-Security" (please replace cloud.nextcloud.com with your url).
Hi all, in order to help people.... I am running nextcloud on ubuntu (apache). I had the waring mentionned by @pottersfield whereas I followed the nextcloud documentation saying you have to add this line: Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
First I set this line in my /etc/apache2/sites-enabled/nextcloud.conf And it didn't remove the warning raised by Nextcloud.
I found the solution here https://www.reddit.com/r/NextCloud/comments/euf8oe/help_issue_with_stricttransportsecurity_security/ where the user said that this line has to be added in file nextcloud-le-ssl.conf.
I did it and it worked for me, no more warning!
@kesselb this check curl -I https://cloud.nextcloud.com | grep "Strict-Transport-Security" is not efficient in the sense that it does not find "Stric-Transport-Security" whereas the Nextcloud warning is no more there..
Hope this helps!