$_ BSDHowTo.ch
How To... Why not..? Scripts Patches RSS logo

How to get rid of all the warnings in Nextcloud

Last update: 2019-05-12


After the installation of Nextcloud you check for security & setup warnings in the administration panel. Although you followed the pkg-readme for Nextcloud to the point you get some yellow entries there. In this article I show you how you can get rid of these.

Before we start

For this how to I assume that you install your Nextcloud on OpenBSD

Blocking access to data directory

The security check gives you the following red error:

Your data directory and files are probably accessible from the Internet.

You have a number of location lines in your httpd.conf(5) that should block access to sensible files and directories of your Nextcloud installation. Just prepend the name on each of these lines with the path /nextcloud:

location "/nextcloud/.ht*"      { block }
location "/nextcloud/.user*"    { block }
location "/nextcloud/3rdparty*" { block }
location "/nextcloud/AUTHORS"   { block }
location "/nextcloud/COPYING"   { block }
location "/nextcloud/config*"   { block }
location "/nextcloud/console*"  { block }
location "/nextcloud/data*"     { block }
location "/nextcloud/lib*"      { block }
location "/nextcloud/occ*"      { block }

Properly resolve different paths

You see four warnings that start with “Your web server is not properly set up to resolve” followed by these paths:

Add the following location blocks to your httpd.conf(5) and the warnings are gone:

location match "/nextcloud/oc[ms]%-provider/*" {
    directory index index.php

location "/.well-known/caldav" {
    block return 301 "https://$SERVER_NAME/nextcloud/remote.php/dav"

location "/.well-known/carddav" {
    block return 301 "https://$SERVER_NAME/nextcloud/remote.php/dav"

Warnings about PHP

The check shows you two error messages about PHP:

To make these two disappear you can add the following two lines to /etc/php-fpm.conf:

env[PATH] = /usr/local/bin:/usr/bin:/bin
php_admin_value[memory_limit] = 512M

Another complaint by Nextcloud is that the module imagick is missing. You can add this module by installing and enabling it:

$ doas pkg_add -i pecl71-imagick
$ cd /etc/php-7.1.sample
$ doas ln -sf ../php-7.1.sample/imagick.ini ../php-7.1/

Don’t forget to restart php-fpm:

$ doas rcctl restart php71_fpm

Different user of directories

Nextcloud check complains about a long list of directories which are not owned by the user the web server is running under (www). You can change this with the following command:

$ find /var/www/nextcloud/apps -type d -exec doas chown www {} \;

I strongly recommend you to do this because it will allow Nextcloud to update the installed apps and install new ones.