A lightweight, password-protected HTTP file server written in Python.
It serves directory listings, supports a public folder with redirect behavior, hides hidden files, and is fully configurable via a .env file.
- 🔒 Basic authentication with SHA256 password hashing
- 📁 Directory listing (excluding hidden files)
- 🌐 Public folder that does not show directory index
- 🔁 Public folder can optionally redirect to a URL
- 🔄 Configurable file transfer method:
copyfileorsendfile - ⚙️
.envsupport for clean configuration - 🧵 Threaded server for concurrent downloads
- 📦 Docker and systemd compatible
- 🧪 Interactive setup with
--set-userand--set-pass
- Python 3.7+
python-dotenv
Install with:
pip3 install python-dotenvCreate a .env file in the same directory as auth_server.py:
AUTH_USERNAME=peoriait
AUTH_PASSWORD_HASH=<your_sha256_hash>
AUTH_PORT=8080
AUTH_PUBLIC_DIR=public
AUTH_SERVE_DIR=.
AUTH_PUBLIC_REDIRECT=https://www.peoriait.com
TRANSFER_METHOD=copyfileTo create a password hash:
python3 auth_server.py --set-userOr to just update the password:
python3 auth_server.py --set-passThis safely hashes the password and updates your .env.
Start the server:
python3 auth_server.pyServe from a different port or public directory:
python3 auth_server.py --port 9090 --public-dir media- Files inside the public folder do not require authentication
- Directories inside it are not listed
- Accessing the folder root (e.g.
/public/) redirects toAUTH_PUBLIC_REDIRECT
You can choose between two file transfer methods:
| Method | Description | Recommended when… |
|---|---|---|
copyfile |
Buffered transfer (safe, default) | ✅ Portable and stable everywhere |
sendfile |
Zero-copy OS syscall (faster) |
Set in .env:
TRANSFER_METHOD=copyfileTo test raw performance of the server, try curl or wget:
curl -O http://<host>:<port>/<filename>If you'd like to run this with Docker Compose:
version: '3.8'
services:
auth-server:
image: python:3
working_dir: /app
volumes:
- ./auth_server.py:/app/auth_server.py
- ./files:/app/files
- ./public:/app/files/public
- ./auth.env:/app/.env
ports:
- "8080:8080"
command: python3 auth_server.pyYou can also run this as a service. Create a systemd file like:
[Unit]
Description=Python Auth File Server
After=network.target
[Service]
ExecStart=/usr/bin/python3 /opt/auth-server/auth_server.py
WorkingDirectory=/opt/auth-server
EnvironmentFile=/opt/auth-server/.env
Restart=always
[Install]
WantedBy=multi-user.targetEnable with:
sudo systemctl daemon-reexec
sudo systemctl enable --now auth-server- All credentials are stored in
.env— protect it like a password - SHA256 is used for password hashing, not bcrypt (for simplicity)
- No HTTPS built-in — use a reverse proxy (like Nginx) for encryption
Built with ❤️ by PeoriaIT.
MIT