User Tools

Site Tools


sysadmin:nextcloud

Installing NextCloud

...with Shared USB Storage

(Random notes that may help - This doc handles the Nextcloud bug and bogus OpenAI instructions)

Components:

  • MiniPC N150 Intel ~ $150 (Amazon)
  • USB to Sata Drive (2 drives) - ~ $30 (Amazon)
  • 6TB SATA Drive HDD, open Box - ~85 (Ebay)
  • 1TB SATA Drive HDD (I had lying around)

Unusuals: This might be unique to my config, so just a heads up.

  • I’m using NGINX as a proxy and Apache as my server.
  • I’m also using Certbot for certificates

Step 1 - Wiped Windows 11 Pro and installed Linux Mint 22, which is based off of Ubuntu which in turn is based off debian (Debian / Ubuntu will work just as well)

Step 2- Installed USB Drives and made them part of my /etc/fstab

Type blkid to get the UUID of the device.. One drive was already EXT2 file system while I ran an MKFS on the larger drive and created an EXT4 file system. Side note: The 6TB drive was a data center drive and partitioned. I needed to remove sdb1 and sdb2 and just have /dev/sdb before creating the file system.

Step 3 - Create the following groups; nextcloud, fileshare and smbuser

Step 4 - Created the user nextcloud and smbuser and added them to the group fileshare

sudo usermod -aG fileshare smbuser
sudo usermod -aG fileshare nextcloud

Step 5 - Ran an apt update/upgrade on the machine

Step 6 - Installed Apache2 and MariabDB via apt install (See appendix A for Apache Configuration)

Step 7 - Followed the Nextcloud documentation, including Mariadb instructions, but here are some clarifications:

  • Went to the nextcloud site and downloaded the zip file (called latest.zip)
  • Unzipped the file under /var/www/html (it will create a sub-directory called nextcloud).This NEEDS to be reflected in your Apache configuration file.
  • Added subdirectories to my drives. So I have two drives (usb-1000G and usb6000G) and create a subdirectory called nextcloud on each.
  • /usb-1000G/nextcloud - This will be mounted to nextcloud
  • /usb-1000G/nextcloud - This WON’T BE mounted by nextcloud, but by Samba
  • chown -R nextcloud:fileshare /usb-1000G/nextcloud
  • When Apache, MySQL, etc. are installed, you can go to the IP address of your server and finish the configuration there. It will install tables under the nextcloud database.

Step 8 - NOTE !!!!! There are BUGS IN NEXTCLOUD AND OPENAI JUST GIVES BS ANSWERS, so this works when creating shareable drives on USB. The GUI DOES NOT WORK !!!!

The following are instructions on mounting the external drive to nextcloud, have it managed by group ‘admin’ and be shareable

Add the drive via occ command

sudo -u www-data php /var/www/html/nextcloud/occ files_external:create  \
"public" \
local \
null::null \
-c datadir=/usb-1000G/nextcloud

Get the mount number

sudo -u www-data php /var/www/html/nextcloud/occ files_external:list

Make “admin” own the drive, not public (this is what I wanted)

sudo -u www-data php /var/www/html/nextcloud/occ files_external:applicable 7 --add-group admin

Make it so admin can share directories on the drive

sudo -u www-data php /var/www/html/nextcloud/occ files_external:option 7 enable_sharing true 

Appendix A - Running Samba along Nextcloud

I want to run SAMBA alongside Nextcloud, so with that, here’s my 2 cents.

  • Run nextcloud to collaborate and use it as a file dump
  • Have the nextcloud drive mounted R/O for Samba
  • When working on files (like editing), copy the files from the nextcloud drive to any other drive, including network or local drive
  • When sharing back, you’ll need to copy the contents via the nextcloud interface.

Appendix B - Apache Configuration On NextCloud Server

NOTE: Certs are handled on the front-end proxy

Alias /nextcloud "/var/www/html/nextcloud/"

<Directory /var/www/html/nextcloud/>
  Require all granted
  AllowOverride All
  Options FollowSymLinks MultiViews

  <IfModule mod_dav.c>
    Dav off
  </IfModule>

</Directory>

<VirtualHost *:80>
  ServerName  cloud.xxxxx.com

  DocumentRoot /var/www/html/nextcloud/

  <Directory /var/www/html/nextcloud/>
    Require all granted
    AllowOverride All
    Options FollowSymLinks MultiViews

    <IfModule mod_dav.c>
      Dav off
    </IfModule>
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Appendix C - NGINX Configuration On Proxy (Main)

server {
    if ($host = cloud.xxxxx.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen      80;
        server_name cloud.xxxxx.com;

        location / {
            proxy_ssl_certificate         /etc/nginx/client.pem;
            proxy_ssl_certificate_key     /etc/nginx/client.key;
            proxy_ssl_protocols           TLSv1 TLSv1.1 TLSv1.2;
            proxy_ssl_ciphers             HIGH:!aNULL:!MD5;
            proxy_ssl_trusted_certificate /etc/nginx/trusted_ca_cert.crt;

            proxy_ssl_verify        on;
            proxy_ssl_verify_depth  2;
            proxy_ssl_session_reuse on;
        }
}

    server {
        listen      443 ssl;
        server_name cloud.xxxxxx.com;

        client_max_body_size 10G;
        client_body_buffer_size 400M;
        location / {
            proxy_pass http://xxx.xxx.xxx.xxx
            proxy_set_header X-Forwarded-Proto https;
        }
        error_log /var/log/nginx/xxxxx_cloud_error.log;
        access_log /var/log/nginx/xxxxx_cloud_access.log;

   ssl_certificate /etc/letsencrypt/live/cloud.xxxxx.com/fullchain.pem; # managed by Certbot
   ssl_certificate_key /etc/letsencrypt/live/cloud.xxxxx.com/privkey.pem; # managed by Certbot
}
sysadmin/nextcloud.txt · Last modified: by mlivolsi