git.sophuwu.com > cdn
simple file server with a thumbnail generation and caching for pictures and mp4 files
Clone this repository git clone https://git.sophuwu.com/cdn

Nice HTTP Server for file sharing

the repo is called ‘cdn’ because it’s a short name. This is just a HTTP server made for file sharing. With some nice features…

Features

Pretty Front-end

Installation

Build with Go

Clone the repository and build it with Go. Make sure you have Go installed on your system.

git clone git.sophuwu.com/cdn
cd cdn
go build -ldflags="-w -s" -trimpath -o build/

The binary will be created in the build/ directory.

Run the server

To run the server, you need to set the environment variables for the port, address, HTTP directory, and database path. You can do this in your terminal or create a .env file.

Variables

Example 1

export PORT=8069
export ADDR=0.0.0.0
export HTTP_DIR=/path/to/your/files
export DB_PATH=/dir/dir/thumbnails.db
./build/cdn

Example 2

PORT=8069 ADDR=0.0.0.0 HTTP_DIR=/path/to/your/files DB_PATH=/dir/dir/thumbnails.db ./build/cdn

Installation after build

sudo install ./build/cdn /usr/local/bin/cdnd

Systemd Service

Edit the cdnd.service file and put it in /etc/systemd/system/. Make sure to set the correct paths for HTTP_DIR and DB_PATH.

If you prefer to write the service file manually, here is an example:

[Unit]
Description=File Sharing HTTP Server
After=network.target

[Service]
WorkingDirectory=/home/httpuser/files
ExecStart=/usr/local/bin/cdnd
Type=simple

User=httpuser

Environment=DB_PATH=/home/httpuser/files.db
Environment=HTTP_DIR=/home/httpuser/files
Environment=PORT=9889
Environment=ADDR=127.0.0.1

[Install]
WantedBy=multi-user.target

Then run:

sudo systemctl daemon-reload
sudo systemctl enable cdnd
sudo systemctl start cdnd