Setting Up Droppy in freeBSD

This is installation was done on a FreeBSD server, though it should work on ubuntu/debain and most other distros.

What is Droppy

Droppy is a self-hosted file storage server with a web interface and capabilities to edit files and view media directly in the browser. It very light-weight and easy to setup compared to NextCloud or OwnCloud.

Pre-requests

  • Node.js >= 12.10.0

  • :)

Installation

Begin by installing droppy on your server, it may require root access to install globally.

npm install -g droppy

Now create `droppies` files and config directories in `/var/www`

#Ubuntu
mkdir -p /var/www/droppy/files
mkdir -p /var/www/droppy/config

#FreeBSD
mkdir -p /usr/local/www/droppy/files
mkdir -p /usr/local/www/droppy/config

Start Droppy!

#Ubuntu
droppy -c /var/www/droppy/config -f /var/www/droppy/files

#FreeBSD
droppy -c /usr/local/www/droppy/config -f /usr/local/www/droppy/files

Thats it! it should be now in port `8989`, you can navigate to `localhost:8989` if droppy is running localy, otherwise you can foreward the port to your local machine with:

ssh -L 8989:localhost:8989 user@serverAdress

You should be able to setup your admin Username and Password

Using Nginx

You probably want to use Droppy without needing to forward ports each time, and might want a sub-domain. (https://droppy.yourDomain.tld)

Installing Nginx

Installing certbot

Certbot - Certbot Instructions have great instructions for installing certbot.

Configuring Nginx

  1. Forward all http requests to https by editing `/etc/nginx/nginx.conf` on Ubuntu or `/usr/local/etc/nginx/nginx.conf` in freeBSD

    
    #user  nobody;
    worker_processes  1;
    
    events {
      worker_connections  1024;
    }
    
    
    http {
    
          server {
                   listen       80 default_server;
                   server_name  _;
    
                   return 301 https://$host$request_uri;
    
          }
      include       mime.types;
      default_type  application/octet-stream;
      include /usr/local/etc/nginx/sites-enabled/*; #FREEBSD format
      include /etc/nginx/sites-enabled/*;           #UBUNTU format
    
      access_log off;
      error_log /dev/null;
      sendfile        on;
      keepalive_timeout  65;
      gzip  on; #Optimzation
    }
  2. For each sub-domain add a config file to etc/nginx/sites-enabled/( or /usr/local/etc/nginx/sites-enabled in FreeBSD)

For our case, we will add a file named droppy.conf

touch /usr/local/etc/nginx/sites-enabled/droppy.conf #FREEBSD
touch /etc/nginx/sites-enabled/droppy.conf           #UBUNTU

In this file you will add the following, ( edit the path to your SSL certificate that you got from certbot)


server {
        listen              443 ssl;
        server_name         droppy.yourDomain.com www.droppy.yourDomain.com;
        ssl_certificate     /path/to/certificate;
        ssl_certificate_key /path/to/certificate/key;
        client_max_body_size 0;

        #Certificte path in freeBSD /usr/local/etc/letsencrypt/live/XXXXXX/fullchain.pem;
        #Certificte key path in freeBSD /usr/local/etc/letsencrypt/live/XXXXXX/privkey.pem;

        #Certificte path in Ubuntu /etc/letsencrypt/live/XXXXXX/fullchain.pem;
        #Certificte key path in Ubuntu /etc/letsencrypt/live/XXXXXX/privkey.pem;

        location / {

                proxy_pass http://localhost:8989;
               proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection 'upgrade';
                proxy_set_header Host $host;
                proxy_cache_bypass $http_upgrade;


        }

}

Now you can start Nginx, with

sudo service nginx start #freeBSD
sudo systemctl start nginx #Ubuntu

Demonize droppy with pm2

First install pm2

npm install -g pm2

To get the automatically-configured startup script for your machine you need to type this command:

pm2 startup

Copy and paste the ouput given by pm2

create the package.json for droppy

touch /usr/local/www/droppy/package.json #freeBSD
touch /var/www/droppy/package.json #Ubuntu

Then add the following to it ( note the difference in paths between FreeBSD/Ubuntu )

{
  "name": "droppy",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "sudo droppy start -c /usr/local/www/droppy/config/ -f /usr/local/www/droppy/files/" //FreeBSD
    "start": "sudo droppy start -c /var/www/droppy/config/ -f /var/www/droppy/files/" //Ubuntu
  }
}

Make sure that you are in the droppy folder then start pm2

cd /usr/local/www/droppy #FreeBSD
cd /var/www/droppy #Ubuntu

sudo pm2 start --name=droppy npm -- start
sudo pm2 save

Yay!

Thats it! You should be able to browse to your domain and start using droppy!