Skip to content
/ airlift Public
forked from moshee/airlift

A self-hosted file upload and sharing service

License

Notifications You must be signed in to change notification settings

lulezi/airlift

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Airlift 📦

Build Status

Airlift is a self-hosted file upload and sharing service. The clients upload files to the server and return a nice link for you to share. Just bring your own server and domain.

💣 This is unstable software. It is not feature-complete and has lots of bugs.

You should use deuiore/load.link instead of this if...

  • ...you like PHP;
  • ...you don't like me;
  • ...you're on a free/cheap shared host that doesn't allow long-running processes.

Clients

airliftd

airliftd is the Airlift server. You drop the server on any dedicated, VPS, shared host, whatever, as long as it supports running a binary and gives you access to ports or frontend server reverse proxying. A client sends files to it and recieves nice URLs to share. The server itself also provides a web-based client to upload files from, as well as manage existing uploads and customize some behaviors.

The server is packaged as a statically compiled binary with a few text assets with no system dependencies apart from maybe libc for networking. Just download (or clone and build), add to your init system of choice, and run.

You can choose to run it behind a frontend server or standalone.

Installing

If you just want a binary

Download a release from the GitHub Releases tab. Put the included binary wherever you want in your $PATH.

Or if you want to build it yourself

  1. Install Go and git
  2. If you don't already have a GOPATH: $ mkdir ~/go && export GOPATH=~/go (you can use any place as your GOPATH)
  3. $ go get ktkr.us/pkg/airlift/cmd/airliftd

I haven't tried to build or run it on Windows, YMMV. Works on macOS and GNU+Linux.

Updating

  1. Replace binary with new one.
  2. There is no step 2.

Usage

To run server:

$ airliftd

In development, you can pass the flag -rsrc . to instruct it to load files from disk rooted in the working directory.

The server runs in the console. You can use whatever tools you want to background it.

Command line options

Usage of airliftd:
  -debug
        Enable debug/pprof server
  -p int
        Override port in config (default -1)
  -rsrc DIR
        Look for static and template resources in DIR (empty = use embedded resources)
  -v    Show version and exit

Sample nginx config

server {
	listen 80;
	server_name i.example.com;
	location / {
		proxy_pass http://localhost:60606;

		# tell the proxied server its own host (not localhost)
		proxy_set_header Host $http_host;

		# tell the proxied server the remote host (not localhost either)
		proxy_set_header X-Forwarded-For $remote_addr;
	}
}

Configuration settings

When you start the server for the first time, it will generate a dotfolder in your home directory for local configuration. Visit http(s)://<yourhost>/config to set up a password and change other configuration parameters. On the first setup, an empty password will not be accepted.

If you manually edit the config file while the server is running, you should send the server process a SIGHUP to force a config reload.

If the server fails to start with a config error, you probably want to delete ~/.airlift-server/config and reconfigure from scratch.

Base URL []: The base URL that links will be returned on. This includes domain and path.

If you are proxying the server behind a frontend at a certain subdirectory, make sure you rewrite the leading path out of the request URL so that the URLs sent to airlift are rooted. Unfortunately, since URLs are rewritten, the redirecting behavior of /-/login and /-/config won't work properly, so you'll have to do your configuration on the internal port (60606 or whatever). Could use a meta redirect instead of internal redirect to fix this, but that doesn't play well with how sessions and stuff are set up in here.

Leaving the host field empty will cause the server to return whatever host the file was posted to.

Length of File ID [4]: Number of characters in subsequently generated file IDs. In general, more characters gives better collision characteristics (and are harder to guess).

Append File Extensions [off]: If enabled, links generated by the upload tool will end with the original file's extension, e.g. i.example.com/f9gW.zip instead of i.example.com/f9gW.

Limit Upload Age [off]: Enable this to automatically limit the maximum age of uploads by periodically pruning old uploads.

Max Age [0]: If Limit Upload Age is on, uploads older than this number of days will be automatically deleted.

Limit Total Uploads Size [off]: Enable this to automatically limit the size of the uploads folder on disk.

Max Size [0]: If Limit Total Uploads Size is on, the oldest uploads will be pruned on every new upload until the total size is less than this many megabytes.

Enable Twitter Cards [off]: If enabled, image uploads (which can be thumbnailed) will provide a Twitter Card preview when their URLs are mentioned in Tweets. This is achieved by serving an alternate page with relevant metadata for the file when the User-Agent of the visitor includes Twitterbot.

Twitter Handle []: Twitter Cards require that the Twitter handle of the source's creator is included in the metadata.

Syntax Highlighting [off]: Enable to serve text-based files with syntax highlighting. The raw file can be requested by appending ?raw=1 to the URL.

Syntax Theme []: Set the syntax highlighting color scheme.

Upload Directory [~/.airlift-server/uploads]: This is where uploaded files will be stored.

New Password []: Change your password here.

Confirm New Password []: Enter the new password again to confirm.

HTTPS

In order to use SSL/TLS standalone, set the following environment variables:

Variable Value
GAS_TLS_PORT The port for the secure server to listen on
GAS_TLS_CERT The path to your certificate
GAS_TLS_KEY The path to your key
GAS_PORT Optional: set this to -1 if you only want HTTPS, not regular HTTP.

If both HTTP and HTTPS are enabled, they will both serve from the same executable and HTTP requests will redirect to HTTPS.

Development

  • After making modifications to static assets, use go generate in cmd/airliftd to create the source files for them
  • After tagging a release, use cmd/airlift/gen_version.bash to create the source file with the tagged version
  • Build with go build

About

A self-hosted file upload and sharing service

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 82.4%
  • JavaScript 9.5%
  • CSS 7.7%
  • Other 0.4%