server icon indicating copy to clipboard operation
server copied to clipboard

Unable to change Strict-Transport-Security settings

Open ghost opened this issue 7 years ago • 4 comments

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 Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"

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

Dav on

SetEnv HOME /var/www/nextcloud SetEnv HTTP_HOME /var/www/nextcloud

ServerName nextcloud15.ddns.net ServerAdmin webmaster@localhost DocumentRoot /var/www/nextcloud/ Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains" ; preload

( 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

ghost avatar May 19 '19 13:05 ghost

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>?).

DrRSatzteil avatar May 20 '19 14:05 DrRSatzteil

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 avatar Oct 07 '19 19:10 ugokanain

@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).

kesselb avatar Oct 07 '19 20:10 kesselb

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!

fred-the-coder avatar Nov 18 '23 10:11 fred-the-coder