Linux Format

Build a better Nextcloud

Christian Cawley shows you how to get the most out of your Raspberry Pi-powered Nextcloud server.

- Christian Cawley Like Little Jack Horner, Christian Cawley has been playing with Raspberry Pi for years, even sticking in his thumb (drive) and pulling out a plum, and completely losing the allegory.

Christian Cawley demonstrat­es how to get the most out of your Raspberry Pi-powered Nextcloud server.

Running your own cloud storage server saves money, allows you to expand storage as necessary, and can be done with a device as small as a Raspberry Pi. Our previous guide to setting up a Nextcloud server on the Raspberry Pi (LXF280) covered everything you need to know about installing and setting up NextCloudP­i and the Nextcloud Ubuntu Appliance, as well as the manual installati­on of Nextcloud on Raspberry Pi OS.

But with the software installed and connected to your network, the job is only half-done. You still need to configure it for your specific use-case, enable external storage to reduce wear and tear on the Pi’s SD card, and make the Nextcloud server accessible from beyond your home network.

The most straightfo­rward way to set up external access to Nextcloud and to add external storage is to do it with the NextCloudP­i installati­on.

External storage

The Raspberry Pi 3 and 4 boot from the SD card. While this can be changed in favour of a more reliable USB device, SD is the default option.

This has obvious advantages, from speed and convenienc­e to simplicity. However, there is a key disadvanta­ge, which is the longevity of the card: regular reading and writing of data to the SD card will shorten its lifespan.

Throw into the mix the fact that your NextCloudP­i storage installati­on is limited to the size of the microSD card in your Raspberry Pi and you have an obvious problem. It’s just not big enough to compete with Dropbox or OneDrive or Google Drive, and you’re limited to the maximum supported capacity of 1TB.

Adding an external disk drive to Nextcloud requires only a device with USB connectivi­ty (unless you’re using a case with a SATA adapter) . For faster data transfer, use USB 3.0+ devices, and for the optimum, rely on SSD or NVME/M.2 flash.

First, connect the USB device and then set up an SSH terminal to your Nextcloud and enter

sudo mkdir /media/USBstorage

In your computer’s web browser visit the NextCloudP­i web panel (using the 4443 port, so https://[IP ADDRESS]:4443) and start the wizard if it doesn’t launch automatica­lly by clicking the wand icon in the toolbar. Select USB Configurat­ion, input Yes, then Continue, and Format USB.

When this completes, select ‘Move data to USB’. You now have a Raspberry Pi-powered Nextcloud server that can store as much data as you need without wearing out the microSD card.

Static access

Configurin­g Nextcloud to be accessed from devices beyond your network (such as your mobile device while shopping) is possible with a static IP address. But before setting this up for external access, it’s smart to configure the Raspberry Pi with a static IP address for access within your network – and, more crucially, your router – first.

To confirm the Pi’s IP address and how it was assigned, open a terminal or SSH connection and enter

ip r | grep default

If you see the letters dhcp the IP address is assigned dynamicall­y by the router. Make a note of the IP address, then check the nameserver or DNS IP:

sudo nano /etc/resolv.conf

Make a note of the IP address listed here for the nameserver before proceeding. Setting a static IP address can be achieved by editing the dhcpcd.conf file in nano:

sudo nano /etc/dhcpcd.conf

Add the following lines to the end of the file, changing the capitalise­d text with the informatio­n you have to hand:

interface NETWORK static ip_address=STATIC_IP/24 static routers=ROUTER_IP static domain_name_servers=DNS_IP

Change NETWORK to eth0 or wlan0 , depending on the network type (Ethernet or Wi-Fi).

For STATIC_IP enter the IP address you wish to use for the Pi – it’s smart to use the one already assigned to maintain connectivi­ty.

For ROUTER_IP , use the gateway IP for the router on your network – this address is usually printed on the router.

Finally, set DNS_IP to the IP address you made a note of after checking the resolv.conf file. Finish by rebooting with

sudo reboot

Confirm the changes with Ctrl+X, then Y and Enter, and reboot. You can check the static IP address has been applied using

ip r | grep default

If you can’t get a static IP address from your ISP – and many of them don’t provide one (see boxout) – your best option for accessing the Nextcloud from anywhere is with a dynamic DNS provider.

Access anywhere

Start by accessing your NextCloudP­i web panel and enter the credential­s you used during setup.

In the web panel, find Networking and select ‘letsencryp­t’ from the menu. Add a working email address when prompted and click the wand icon to launch the setup wizard and select ‘External access’. Answer Yes, then wait for setup to complete. When prompted for Port forwarding, choose ‘I will do it manually’.

You’ll need to forward ports 443 and 80 (for HTTPS and HTTP) to the Raspberry Pi, targeting the routerassi­gned IP address for the device or its hostname ( nextcloudp­i ). How you do this will differ from router to router. Many routers offer an online help tool, but you can also refer to the device’s documentat­ion to find out how to use port forwarding.

In the next screen, sign up to FreeDNS when prompted, select Subdomains and choose a free domain and subdomain, then input your router’s public IP address (check by searching Google for ‘what is my IP’) and Save.

Next, choose Dynamic DNS and copy the Direct URL for your subdomain into a text file. Remove everything before (and including) the ? so you’re left with a long alphanumer­ic string. On the FreeDNS screen in NextCloudP­i, complete the Domain field with the subdomain you chose, then paste the alphanumer­ic hash from the text file into the Update Hash field and click Finish to complete.

With your Nextcloud installati­on now fully online it should be accessible from the mobile app or any other device through your browser.

Note that by establishi­ng a static IP you may need to create a new connection in whichever version of the Nextcloud app you’re using.

Enhance with apps

With the Nextcloud server accessible from anywhere, there are a few things you can do to take it to the next level. Almost all those things can be found in the apps list. These were mentioned in the previous tutorial but there are several that can really enhance your Raspberry Pi cloud server if you’re planning on using it for a home file and media server.

In the Featured Apps list, you’ll find a list of snaps that are listed by type. In the Multimedia tab you’ll find apps for playing media. There is also an app called Automated Media Conversion which converts media files using FFmpeg based on rules that you set. It can also convert files as they’re uploaded.

Antivirus and anti-ransomware apps can also be installed to protect your cloud data, along with integratio­ns with mainstream cloud solutions. This is useful for easily migrating your cloud storage across rather than downloadin­g to a PC and then uploading to the Nextcloud server.

 ??  ?? Connect a USB drive or full-size external hard disk drive to your Raspberry Pi for storage with Nextcloud - USB 3.0 preferred!
Connect a USB drive or full-size external hard disk drive to your Raspberry Pi for storage with Nextcloud - USB 3.0 preferred!
 ??  ??
 ??  ?? Set up cloud storage that you can access across the internet by configurin­g port forwarding via static IP or dynamic DNS.
Set up cloud storage that you can access across the internet by configurin­g port forwarding via static IP or dynamic DNS.

Newspapers in English

Newspapers from Australia