Accessing Nextcloud from the Internet

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 with the following content:

<VirtualHost *:80>
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log

Make sure the file end with an empty line!

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

Edit file /var/www/html/nextcloud/config/config.php. Add in the ‘trusted_domains’ array .
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 <> –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:

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>
   <meta http-equiv="refresh" content="0;URL=wordpress/index.php">

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

Previous pageNext page