First of all, your internet domain must be added to the Apache HTTP server.
Create a conf file with your domain name on location
/etc/apache2/sites-available; (eg www.mijndomein.nl) with the following content:

<VirtualHost *:80>
        ServerName www.mijndomein.nl
    ServerAlias
        ServerAdmin naam@mail.nl
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
</VirtualHost>

Make sure the file end with an empty line!

Then run the following command: sudo a2ensite www.mijndomein.nl to enable this configuration.

Edit file /var/www/html/nextcloud/config/config.php. Add in the ’trusted_domains’ array www.mijndomein.nl .
Now is the time to configure port forwarding in the router of your network for ports 80 and 443 to the Raspberry pi.
NextCloud must, via your internet domain, be called via a secure HTTPS URL. You need a certificate for this.
Install: apt-get install python-certbot-apache
Then run the following command:
certbot –authenticator <www.mijndomein.nl> –installer apache
You now go through a number of choices and at some point you have to supply the webroot. This is the DocumentRoot of the VirtualHost (ie /var/www/html).
Then also choose to perform a redirect from http to https.
After this, Nextcloud can only be accessed via a https URL: https://www.mijndomein.nl/nextcloud

I have chosen to place Nextcloud in /nextcloud and not in the root of my domain. This gives me the possibility to call other applications (such as WordPress) via my domain.
However, I want to prevent someone from snooping around in the DocumentRoot. I therefore gave file /var/www/html/index.html the following content:

<!DOCTYPE html>
<html>
<head>
   <meta http-equiv="refresh" content="0;URL=wordpress/index.php">
</head>
</html>

You can also do this via the .htaccess file, but I found this solution more understandable.


Previous pageNext page