Skip to content

Setting up Nextcloud, MySQL, SSL with docker compose

Notifications You must be signed in to change notification settings

manuela2013/nextcloud

 
 

Repository files navigation

Your own nextcloud with collabora office

For a comprehensive explanation how to use this project, I highly recommend to read my Blog Post.

The impatient ones can try to continue without reading the longer post:

Steps without really explanations

Important
We are assuming: You have docker, docker-compose installed on your system, or you can do this just now. You have a linux system available that could be reached from the internet. Either directly, or via port forwarding.

Clone the repo

cd <folder where you want the system to be installed>
git clone git@github.com:gorzala/nextcloud.git
# do not rename the clone base folder "nextcloud" !

Create files for credentials

cd nextcloud;
# I will refer to this folder as <nextcloud-home>
mv .env-template .env

With an text editor, open the file <nextcloud-home>.env.

Provide for the entries proper values:

  • MYSQL_ROOT_PASSWORD should be set to the value for the root password that is used when MySQL will be initialized.

  • MYSQL_PASSWORD should be set to the value that is being used for the nextcloud (logical) database

Create Folder Setup

With an text editor, open the file <nextcloud-home>.maintenance.config and check the values for the following key and change them to match your system:

  • BASE_FOLDER should point to the root of the repository that you checked out

  • NEXTCLOUD_DATA_FOLDER should point the folder that will contain the files from your users. On my system I put them onto an external drive and set the value accordingly.

The other folders that are configured in this files, will be resolved relative to the BASE_FOLDER.

Setting up DNS

Assuming you are setting up an Nextcloud Server under nextcloud.becheftigt.de you have to change the DNS-entry to point to the IP-address (A-Record) of your Server. When your server is behind a router, you have to forward traffic to port 443 to the server that will run Nextcloud.

Start the System

cd <nextcloud-home>
docker-compose up

You will have to wait a while. Without any claim to comprehensiveness let me tell you what is going on here:

  1. Docker will realize that is never have downloaded the needed images and start downloading

  2. When Docker has downloaded the images, it is starting them in the needed order

  3. The configured docker images makes heavy use of volumes. The will realize, that the mount directories one the docker host, does not already exist. Docker will create these folders and will initialize the containers.

    1. Treafik the edge route will detect that the nextcloud container is configured for the host nextcloud.becheftigt.de. It will check for an existing certificate, will not find one in the configured volume letsencrypt and will try to get a new ssl certificate for you. At this point it is necessary, that the dns of nextcloud.becheftigt.de is pointing to to the ip of your server (at least that traffic to this Ip’s port is being forwarded there)

    2. The MySQL container will be initialized. A logical database nextcloud will be created. The credentials will be used from the .env file from the first step.

    3. Nextcloud will be initialised by copying its standard files in the configured volumes.

You can check the volumes, they should now contain files.

Now it’s time to configure you nextcloud installation.

Basic Setup

Start configuration from Nextcloud by opening the following page.

As the first user name, take the username you want to use for yourself when using Nextcloud. Chose an passwort you want.

Then select Maria/Mysql as the used Database system. Provide the following entries:

  • database user: nextcloud

  • database name: nextcloud

  • database pass: <the password from the env file, not the root password>

  • database host: mysql:3306

Deselect that option to install the default apps.

Click ok.

It is likely that you will see an error page.

You have to configure something to get it working:

Fixing some wrong default configurations

Edit in the config volume the file config.php, that it contains the following key-values:

'overwritehost' => 'cloud.becheftigt.de',
'overwriteprotocol' => 'https',
'overwrite.cli.url' => 'https://cloud.becheftigt.de',

In the core volume change the file .htaccess fix the redirection rules (needed for synchronisation with you mobiles).

The rules for the request that start with .well-known* should look like:

RewriteRule ^\.well-known/host-meta https://%{HTTP_HOST}/public.php?service=host-meta [QSA,L]
RewriteRule ^\.well-known/host-meta\.json https://%{HTTP_HOST}/public.php?service=host-meta-json [QSA,L]
RewriteRule ^\.well-known/webfinger https://%{HTTP_HOST}/public.php?service=webfinger [QSA,L]
RewriteRule ^\.well-known/nodeinfo https://%{HTTP_HOST}/public.php?service=nodeinfo [QSA,L]
RewriteRule ^\.well-known/carddav https://%{HTTP_HOST}/remote.php/dav/ [R=301,L]
RewriteRule ^\.well-known/caldav https://%{HTTP_HOST}/remote.php/dav/ [R=301,L]

Further Reading

If you got all running with this amount of explanation, that congrats! (I would like to know this ;-) ) If you run into troubles, I would recommend to longer Post on this topic. Also if you were lucky, i would recommend reading the longer Blog Post., as it could breaden your knowledge about what you have done. Could be especially useful if things break.

About

Setting up Nextcloud, MySQL, SSL with docker compose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%