A lightweight HTTP file server for exposing directory contents over a REST API. Built with Go and packaged as a Docker image for easy deployment.
- Directory Browsing: List directory contents with configurable introspection depth
- File Serving: Serve individual files over HTTP
- API Key Authentication: Secure access with environment-based API keys
- Security Hardening: Built-in helmet middleware for security headers
- Minimal Footprint: Uses scratch-based Docker image for minimal size
The image is available on Docker Hub: blanymon/servelink
docker run -d \
-p 8080:8080 \
-v /path/to/your/files:/app/mnt \
-e SUPER_SECRET_KEY=your-secret-key-here \
blanymon/servelinkversion: '3.8'
services:
servelink:
image: blanymon/servelink
ports:
- "8080:8080"
volumes:
- /path/to/your/files:/app/mnt
environment:
- SUPER_SECRET_KEY=your-secret-key-hereSUPER_SECRET_KEY(required): API key for authentication. All requests must include this key in thex-api-keyheader.
/app/mnt: Mount your files/directories to this path in the container.
GET /dir?introspectionLevel=<level>Query Parameters:
introspectionLevel(optional, default:0): How many levels deep to recursively list subdirectories0: Only list the root directory1: List root and immediate subdirectoriesn: List up to n levels deep
Headers:
x-api-key: Your secret API key
Example:
curl -H "x-api-key: your-secret-key-here" \
"http://localhost:8080/dir?introspectionLevel=2"Response:
{
"Name": ".",
"Path": ".",
"IsDir": true,
"Metadata": null,
"Children": {
"file.txt": {
"Name": "file.txt",
"Path": "mnt/file.txt",
"IsDir": false,
"Metadata": {...},
"Children": {}
},
"subfolder": {
"Name": "subfolder",
"Path": "mnt/subfolder",
"IsDir": true,
"Metadata": {...},
"Children": {...}
}
}
}GET /file/:pathPath Parameters:
path: Relative path to the file (from the mounted/app/mntdirectory)
Headers:
x-api-key: Your secret API key
Example:
curl -H "x-api-key: your-secret-key-here" \
"http://localhost:8080/file/documents/example.pdf" \
-o example.pdf- Always set a strong API key via the
SUPER_SECRET_KEYenvironment variable - All requests require authentication via the
x-api-keyheader - Do not expose the service to the internet without additional security measures (reverse proxy, firewall, etc.)
- The service serves files from the mounted volume - ensure only intended files are accessible
# Clone the repository
git clone https://github.com/floriantranier/servelink.git
cd servelink
# Build the Docker image
docker build -t servelink .
# Run the container
docker run -d \
-p 8080:8080 \
-v /path/to/files:/app/mnt \
-e SUPER_SECRET_KEY=your-secret-key \
servelinkSee the repository for license information.
Florian Tranier