Ratodo

夜半观星

我的花园到处是星星的碎片
telegram
github
email
nintendo switch

NextCloud setup & Aria2 offline

Preface

There are already many tutorials online on how to set up NextCloud. This tutorial is based on my experience in setting up NextCloud and is provided for reference.

NextCloud is known for its excellent cross-platform collaboration capabilities and user-friendly interface. The following instructions will guide you through the installation process using snap.

P.S. The server used in this article is LightSail in Japan, and the operating system is Ubuntu 18.04.

Installation Process

Log in to the server and obtain root privileges.

sudo -i

Enter the following commands:

sudo apt-get update
sudo apt-get install snapd
sudo snap install nextcloud

Wait for a moment, and when the following message appears, the installation is successful.

Pic1

Enter the server IP address in the browser to access the configuration interface.

Pic2

At this point, the installation process is complete.

Enabling HTTPS

After installing the NextCloud server, you need to configure the domain name.

First, make sure to resolve the domain name to your server's IP address before proceeding.

Enter the following command to apply for a Let's Encrypt certificate:

sudo nextcloud.enable-https lets-encrypt

Pic3

I encountered a problem at this step. After deploying the certificate, I couldn't access my domain name and IP address. This issue was resolved after uninstalling and reinstalling.

P.S. Uninstall command: snap remove nextcloud
After reinstalling, you need to reapply for the certificate.

When accessing through the domain name, you may encounter an untrusted domain error, as shown in the image below:

Pic4

To fix this, simply enter the following command:

Replace "domain.com" with your own domain name. If you want to add additional domains, change "1" to "2", and so on.

sudo nextcloud.occ config:system:set trusted_domains 1 --value=domain.com

Now you should be able to access NextCloud normally. The installation is complete.

Using Aria2 for Offline Downloads

If you want to use the server for offline downloading of videos or other resources, you can achieve instant downloads. However, please make sure not to violate the laws and regulations of the country where the server is located, as violating the TOS rules may result in server closure.

First, click on the avatar in the upper right corner, select "Apps", and then click on the disabled app to enable "External storage support".

Back on the server, install Aria2:

wget -N --no-check-certificate https://raw.githubusercontent.com/ToyoDAdoubi/doubi/master/aria2.sh && chmod +x aria2.sh && bash aria2.sh

Pic5

Next, modify the download storage path for Aria2. Open: vi /root/.aria2/aria2.conf and find: dir=XXX. It is recommended to change it to /var/snap/nextcloud/common/nextcloud/data/xxx/files/Downloads (where xxx is the username used during installation).

Pic6

It is also recommended to change the RPC token to a memorable string.

Pic7

After making the changes, restart the Aria2 service by running service aria2 restart.

Now go back to the NextCloud settings page, click on "External storage" under "Administration", and add the local external storage you just configured.

Pic8

Next, download an Aria2 visualization program.
(The following content is quoted from Wazhan Fou)

Quotation begins

AriaNg project:

Project: https://github.com/mayswind/AriaNg
Download: https://github.com/mayswind/AriaNg/releases/latest

AriaNg is a frontend (HTML+JS static) control panel. It does not need to be placed on the same server or device as Aria2 (backend/server). You can download it to your local computer, unzip it, and open index.html, or you can place it on a server and access it. The server only needs Nginx or Apache.

Click on AriaNg settings and enter the RPC alias, address, protocol, request method, and key. Fill in the RPC address with the IP or domain name, and the default port is 6800. The key is the one you modified in the configuration file. (Click to enlarge)

Pic9

After completing the settings, click on Aria2 status to see that Aria2 has successfully connected. If it fails to connect, check if the firewall of the VPS has opened two ports: the RPC listening port 6800 (default) and the BT listening port 51413 (default). After modifying the configuration file, remember to restart the VPS.

Pic9

Open the AriaNg panel, and you can add HTTP or BT magnet links to start downloading.

Pic9

Since we are using a VPS host to download resources, the speed is usually very fast.

Pic9

Quotation ends

!! Make sure to confirm that the download location is set correctly !!

The downloaded files may not appear immediately in NextCloud. You need to use the built-in occ function in NextCloud to refresh the files in the folder.

First, create an executable file in the root directory:

vi /root/nextcloud.sh

Enter the following content:

#!/bin/bash
sudo nextcloud.occ files:scan --all

Save and exit.

Give it executable permissions: chmod 777 nextcloud.sh

Run crontab -e and press Enter.

Add the following code below:

*/1 * * * * /root/nextcloud.sh

Press Ctrl+X to exit, press Y to confirm, and press Enter. The above command means that nextcloud.sh will be executed every minute. You can change it to every 2 minutes or 30 minutes according to your actual needs.

Summary

It is not recommended to use a server in Japan for BT downloads, as it may easily crash.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.