GithubHelp home page GithubHelp logo

thewebsitenursery / droppy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from silverwind/droppy

0.0 2.0 0.0 7.41 MB

Self-hosted file storage server

License: BSD 2-Clause "Simplified" License

Makefile 0.76% JavaScript 77.65% CSS 16.74% HTML 4.61% Shell 0.25%

droppy's Introduction

droppy is a self-hosted file storage server with a web interface and capabilites to edit files and view media directly in the browser. It is particularly well-suited to be run on low-end hardware like the Raspberry Pi.

Features (try the demo)

  • Fully responsive HTML5 interface
  • Realtime updates of changes
  • Directory upload support
  • Drag & drop and swipe gestures
  • Side-by-Side mode
  • Shareable public download links
  • Zip download of directories
  • Powerful editor for text files
  • Image and video gallery, audio player
  • Fullscreen support for media galleries
  • Supports installing to the homescreen

Installation

Note that two directories will be used by droppy:

  • config directory: set with --configdir <dir>, default ~/.droppy/config.
  • files directory: set with --filesdir <dir>, default ~/.droppy/files.

Make sure these directories exist and owned by the user running the application/container.

Local Installation

With Node.js >= 0.10 and npm installed, run:

# Install latest version and dependencies.
$ [sudo] npm install -g droppy

# Start with `/srv/droppy/config` for config and `/srv/droppy/files` for files.
$ droppy start --configdir /srv/droppy/config --filesdir /srv/droppy/files

# Open http://localhost:8989/ in your browser.

Docker installation ๐Ÿณ

# Pull the image and start the container. Port 8989 on the host will be forwarded to the container.
$ docker run --name droppy -p 8989:8989 -v /srv/droppy/config:/config -v /srv/droppy/files:/files silverwind/droppy

# Open http://localhost:8989/ in your browser.

Note: While it's advisable that all files in the config and files directory are owned by the user running the container, changing the ownership of the directories is supported through passing the environment variables UID and GID to the container, e.g. docker run -e UID=1000 -e GID=1000.

Configuration

By default, the server listens on all IPv4 and IPv6 interfaces on port 8989. On first startup, a prompt to create login data for the first account will appear. Once it's created, login credentials are enforced. Additional accounts can be created in the options interface or the command line. Configuration is done in config/config.json, which is created with these defaults:

{
  "listeners" : [
      {
          "host"     : ["0.0.0.0", "::"],
          "port"     : 8989,
          "protocol" : "http"
      }
  ],
  "public"          : false,
  "timestamps"      : true,
  "linkLength"      : 5,
  "logLevel"        : 2,
  "maxFileSize"     : 0,
  "updateInterval"  : 1000,
  "pollingInterval" : 0,
  "keepAlive"       : 20000,
  "allowFrame"      : false
}

Options

  • listeners Array - Defines on which network interfaces, port and protocols the server will listen. See listener options below. listeners has no effect when droppy is used as a module.
  • public Boolean - When enabled, no user authentication is performed.
  • timestamps Boolean - When enabled, adds timestamps to log output.
  • linkLength Number - The amount of characters in a shared link.
  • logLevel Number - Logging amount. 0 is no logging, 1 is errors, 2 is info (HTTP requests), 3 is debug (Websocket communication).
  • maxFileSize Number - The maximum file size in bytes a user can upload in a single file.
  • updateInterval Number - Interval in milliseconds in which a single client can receive update messages through changes in the file system.
  • pollingInterval Number - Interval in milliseconds in which the file system is polled for changes, which is likely necessary for files on external or network-mapped drives. This is CPU-intensive! Corresponds to chokidar's usePolling option. 0 disables polling.
  • keepAlive Number - Interval in milliseconds in which the server sends keepalive message over the websocket, which may be necessary with proxies. 0 disables keepalive messages.
  • allowFrame Boolean - Allow the page to be loaded into a <frame> or <iframe>.
  • dev Boolean - Enable developer mode, skipping resource minification and enabling live reload.
#### Listener Options

listeners defines on which network interfaces, ports and protocol(s) the server will listen. For example:

"listeners": [
    {
        "host"     : [ "0.0.0.0", "::" ],
        "port"     : 80,
        "protocol" : "http"
    },
    {
        "host"     : "0.0.0.0",
        "port"     : 443,
        "protocol" : "https",
        "key"      : "~/certs/tls.key",
        "cert"     : "~/certs/tls.crt",
        "ca"       : "~/certs/tls.ca",
        "dhparam"  : "~/certs/tls.dhparam",
        "hsts"     : 31536000
    }
]

The above configuration will result in:

  • HTTP listening on all IPv4 and IPv6 interfaces, port 80.
  • HTTPS listening on all IPv4 interfaces, port 443, with 1 year of HSTS duration, using the provided SSL/TLS files.

A listener object accepts these options:

  • host String/Array - Network interface(s) to listen on. Required.
  • port Number/Array - Network port(s) to listen on. Required.
  • protocol String - Protocol to use, http or https. Required.

For SSL/TLS these additional options are available:

  • key String - Path to PEM-encoded SSL/TLS private key file. Required.
  • cert String - Path to PEM-encoded SSL/TLS certificate file. Required.
  • ca String - Path to PEM-encoded SSL/TLS intermediate certificate file.
  • dhparam String - Path to PEM-encoded SSL/TLS Diffie-Hellman parameters file. If not provided, new 2048 bit parameters will generated and saved for future use.
  • hsts Number - Length of the HSTS header in seconds. Set to 0 to disable HSTS.

Note: Unless given absolute, SSL/TLS paths are relative to the config folder. If your certificate file includes an concatenated intermediate certificate, it will be detected and used, there's no need to specify ca in this case.

API

droppy can be used with frameworks like express:

var app    = require("express")();
var droppy = require("droppy")({
  configdir: "~/droppy/config"
  filesdir: "~/droppy/files",
  log: "~/droppy/log",
  logLevel: 0
});

app.use("/", droppy);
app.listen(process.env.PORT || 8989);

See the express example for a working example.

droppy([options])

  • options {object}: Options. Extends config.json. In addition to above listed options, configdir, filesdir and log are present on the API.

Returns function onRequest(req, res). All arguments are optional.

Installation guides

Upgrading a local installation

$ [sudo] npm install -g droppy

Upgrading a Docker installation

$ docker pull silverwind/droppy
$ docker stop droppy
$ docker rm droppy
$ docker run --name droppy -p 8989:8989 -v /srv/droppy/config:/config -v /srv/droppy/files:/files silverwind/droppy

Note about startup performance

droppy is currently optimized for a moderate amount of files. To aid in performance, all directories are indexed into memory once on startup. The downside of this is that the startup will take considerable time on slow storage with hundreds of thousands of files present.

Note about wget

For correct download filenames of shared links, use --content-disposition or add this to ~/.wgetrc:

content-disposition = on

ยฉ silverwind, distributed under BSD licence.

droppy's People

Contributors

silverwind avatar poorchop avatar paulmillr avatar gissehel avatar

Watchers

James Cloos avatar The Website Nursery avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.