1
0

nextcloud.md 5.5 KB

Nexctloud

Journey to install Nextcloud on an Ubuntu Server 20.04 LTS instance.

Install

Installed by checking nexcloud on Ubuntu installation wizard. Can be installed later with snap.

Configure proxy

Use case : ports 80 and 443 are directed to my raspberry pi (with local IP 192.168.1.100), and domain name cloud.me.ovh must be redirected to my nexcloud server on IP 192.168.1.110

Configure proxy setting on pi (more info on private httpd repo):

<VirtualHost *:80>
    ServerName cloud.me.ovh
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyPass / http://192.168.1.110/
    ProxyPassReverse / http://192.168.1.110/
</VirtualHost>

Add a file proxy.config.php in folder /var/snap/nextcloud/current/nextcloud/config with following content :

<?php

$CONFIG = [
        'trusted_proxies'   => ['192.168.1.100'],
];

Trust domain

Add a file trust_domain.config.php in folder /var/snap/nextcloud/current/nextcloud/config with following content :

<?php

$CONFIG = [

'trusted_domains' =>
   [
    'cloud.me.ovh',
    '192.168.1.110',
  ],

];

No need to restart system, config is taken into account at web page reload.

Enforce security

On proxy

Follow official instructions on Nextcloud doc

To enable mod_headers on HTTPD : a2enmod headers

On snap installation

sudo nextcloud.enable-https lets-encrypt

Other fixes

As an admin, go to Overview in the Administration panel from Settings. Nexctloud will scan your instance and give you instructions.

TURN Talk

Talk can fail for some users behind annoying firewalls or symmetric NAT.

That can be fixed by using a TURN server.

Synchronisation on Android

Follow these instructions Nextcloud sync documentation.

Warning : if you use an apache proxy, use overwriteprotocol instruction to force https in redirections.

Use OCC

In Ubuntu snap, you can invoke nextcloud CLI with nextcloud.occ command.

Full documentation about OCC on official doc

Migrate data by CLI

First put your files in user space :

sudo cp -a Music /var/snap/nextcloud/common/nextcloud/data/jovian/files/

Then fix ownership of new folder :

sudo chown -R root:root Music

Refresh Nextcloud cache :

sudo nextcloud.occ files:scan --path="/jovian/files/Music"

Apps

Collabora online

Install via CLI with :

sudo -u www-data php -d memory_limit=512M nextcloud.occ app:install richdocumentscode

Migrate to a new installation

References

Official Nextcloud guide to migrate from one server to another

Chronogram

  1. Change DNS record (anticipate propagation time)
  2. Make a fresh installation on a new server
    1. Install OS
    2. Set a unic hostname
    3. Assign a static IP address
    4. Update and reboot
  3. Backup old installation and import data on a new server
    1. Stop services sudo systemctl stop 'snap.nextcloud.*'
    2. Change ownership of common and current in /var/snap/nextcloud to SSH user on target
    3. Transfer files these 2 folders on the new instance (be sure the same version is installed)
    4. Restore folder ownership
    5. Start services sudo systemctl start 'snap.nextcloud.*'
  4. Local test
    1. Browser access
    2. Files available
  5. Make your instance available
    1. Check DNS redirection
    2. Set up reverse-proxy
  6. Online test
    1. Browser access
    2. Files available
    3. PC sync client
    4. Android sync client
    5. Agenda sync
    6. Tasks sync
    7. Money buster sync

Switch to a reverse-proxy

Disable HTTPS with nextcloud.disable-https

Configure HTTPS on reverse-proxy.

Trouble shoot migration

Apps are not working (example from my own migration : Contacts and Tasks not working because of javascript file not found.

I had some errors after rsync about those files. That might be related.

Manage disks

Check health

Check RAID

cat /proc/mdstat

Check individual HDD

smartctl --scan
sudo smartctl -a /dev/sdc

If one the tested disk is failing, write down its serial number and continue with the replacement procedure.

Replace the disk

  1. RAID disconnection
    1. cat /proc/mdstat
    2. mdadm --manage /dev/md0 --fail /dev/sdy1
    3. cat /proc/mdstat
    4. mdadm --manage /dev/md0 --remove /dev/sdy1
    5. cat /proc/mdstat
  2. Physical replacement
    1. Shut down the server
    2. Spot the HDD to remove based on its serial number
    3. Replace it by the new one
    4. Boot the server
    5. Mark the retrieved HDD as dead
  3. RAID update
    1. cat /proc/mdstat
    2. Become superuser
    3. fdisk -l -> spot the device with no partition /dev/sdz
    4. Copy partition information
      1. For MBR partitioning (legacy) : sfdisk -d /dev/sdx | sfdisk /dev/sdz
      2. For GPT partitioning : sgdisk -R /dev/sdz /dev/sdx then sgdisk -G /dev/sdz
    5. fdisk -l -> check that /dev/sdz is partitioned
    6. mdadm --manage /dev/md0 --add /dev/sdz1
    7. cat /proc/mdstat
    8. Hope you first disk won't die during recovery