3 unstable releases
Uses new Rust 2024
new 0.2.1 | May 21, 2025 |
---|---|
0.2.0 | May 21, 2025 |
0.1.0 | May 20, 2025 |
#191 in HTTP server
252 downloads per month
36KB
789 lines
servive - Simple HTTP File Server
A lightweight, secure HTTP file server written in Rust with TLS and basic authentication support.
Features
- Serve files over HTTP/HTTPS
- Basic authentication support
- TLS encryption (via rustls)
- Optional directory listing
- Security headers (CSP, XSS protection, etc.)
- Configurable logging levels
- CLI configuration interface
Installation
From crates.io
cargo install servive
From source
git clone https://github.com/metdxt/servive.git
cd servive
cargo install --path .
Usage
Basic usage
servive -p 8080 -d ./public
With authentication
servive --username admin --password secret
With TLS
servive --tls --tls-cert cert.pem --tls-key key.pem
Disable directory listing
servive --no-list-dirs
With specific bind address
IPv4:
servive -b 192.168.1.100
IPv6:
servive -b ::1
Configuration Options
Option | Description | Default |
---|---|---|
-p , --port |
Port to listen on | 8000 |
-d , --directory |
Directory to serve files from | . (current dir) |
--username |
Username for basic auth | None |
--password |
Password for basic auth | None |
--log-level |
Logging level (error, warn, info, debug, trace) | info |
--tls |
Enable TLS | false |
--tls-cert |
TLS certificate file path | None |
--tls-key |
TLS private key file path | None |
--no-list-dirs |
Disable directory listing | false |
-b , --bind |
Bind address (IPv4 or IPv6) | 127.0.0.1 |
--show-dotfiles |
Show dotfiles (hidden by default) | false |
Security Considerations
- Basic authentication credentials are transmitted in plaintext when not using TLS
- Always use TLS in production environments
- The server adds security headers by default:
- Content-Security-Policy
- X-Content-Type-Options
- X-Frame-Options
- X-XSS-Protection
Building from Source
- Clone the repository:
git clone https://github.com/metdxt/servive.git
cd servive
- Build in release mode:
cargo build --release
The binary will be available at target/release/servive
License
The project is distributed under the MIT license
Dependencies
~11–22MB
~316K SLoC