Files
hardfiles/README.md

149 lines
3.6 KiB
Markdown
Raw Normal View History

2023-10-01 13:43:15 -04:00
# HARDFILES
2023-09-30 18:10:29 -05:00
No logs. No tracking. No analytics. No weird anime girls on the homepage.
2023-09-30 18:10:29 -05:00
Upload a file, get a link, it's shredded in 24 hours.
2023-09-30 18:10:29 -05:00
## Features
2023-10-01 13:43:15 -04:00
- Drag-and-drop, clipboard paste, file picker, and curl uploads
- Optional password protection on files
- 7-pass secure file shredding on expiry
- Random GIF backgrounds from a configurable directory
- IP-based rate limiting
- Streaming uploads (no memory buffering — handles files up to 5GB)
- Single Go binary, no database
2023-12-27 14:48:13 -05:00
## Quick Start
2023-10-01 13:43:15 -04:00
```bash
2023-10-01 13:43:15 -04:00
go build -o hardfiles main.go
./hardfiles
```
Or with Docker:
2023-10-04 01:32:49 +00:00
```bash
docker compose up -d
2023-10-04 01:32:49 +00:00
```
## Configuration
Edit `config.toml`:
```toml
webroot = "www"
lport = "5000"
vhost = "hardfiles.org"
filelen = 6
folder = "files"
bgfolder = "backgrounds"
max_upload_mb = 5120
ttl_hours = 24
rate_limit_per_min = 30
```
2023-10-01 13:43:15 -04:00
## Usage
2023-10-01 13:43:15 -04:00
### Browser
Visit the site, drop a file, get a link.
2023-10-01 13:43:15 -04:00
### curl
```bash
# Upload a file
curl -F file=@photo.png https://hardfiles.org/
2023-10-01 13:43:15 -04:00
# Upload with password
curl -F file=@secret.pdf -F password=hunter2 https://hardfiles.org/
```
2023-10-01 13:43:15 -04:00
### Bash Alias
2023-10-01 13:43:15 -04:00
```bash
# Add to ~/.bashrc
upload() {
curl -F file=@$1 https://hardfiles.org/
2023-10-01 13:43:15 -04:00
}
2023-09-30 18:10:29 -05:00
```
2023-10-01 13:43:15 -04:00
Then just `upload /path/to/file.jpg`.
## Backgrounds
2023-10-01 13:43:15 -04:00
Add .gif files to the `backgrounds/` directory. Each page load picks one at random. The more chaotic, the better.
## Nginx Reverse Proxy
Hardfiles is designed to run behind nginx. Key configuration for large file uploads:
```nginx
server {
listen 443 ssl;
server_name hardfiles.org;
# CRITICAL: Must match or exceed max_upload_mb in config.toml
client_max_body_size 5120m;
# Disable request buffering — stream directly to backend
proxy_request_buffering off;
2023-10-01 13:43:15 -04:00
# Increase timeouts for large uploads
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
proxy_connect_timeout 60s;
2023-10-01 13:43:15 -04:00
# Increase header buffer for large multipart boundaries
proxy_buffer_size 16k;
proxy_buffers 4 32k;
location / {
proxy_pass http://127.0.0.1:5000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
}
ssl_certificate /etc/letsencrypt/live/hardfiles.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/hardfiles.org/privkey.pem;
2023-10-01 13:43:15 -04:00
}
```
**Important nginx settings:**
- `client_max_body_size 5120m` — must match `max_upload_mb` in config.toml, or nginx will reject uploads before they reach hardfiles
- `proxy_request_buffering off` — prevents nginx from buffering the upload to disk before forwarding (critical for memory-limited servers)
- `proxy_read_timeout 3600s` — 1 hour timeout for large uploads on slow connections
2023-10-01 13:43:15 -04:00
## Docker
```bash
# Build and run
docker compose up -d
# Volumes mounted:
# ./files:/app/files — uploaded files (auto-cleared every 24h)
# ./backgrounds:/app/backgrounds — GIF backgrounds
# ./config.toml:/app/config.toml — configuration
2023-10-01 13:43:15 -04:00
```
## Security
2023-10-01 13:43:15 -04:00
- Files are shredded with 7-pass random overwrite before deletion (effective on HDD; ceremonial on SSD — use dm-crypt/LUKS for SSD)
- Path traversal prevention on all routes
- Upload size limits enforced at the HTTP level
- Password-protected files use bcrypt hashing
- MIME type allowlist for inline serving (images, PDFs, text, audio, video) — HTML/SVG/JS forced to download to prevent stored XSS
- Content-Security-Policy headers on all HTML responses
- No file listing or directory browsing
2023-10-01 13:43:15 -04:00
## Credits
- **delorean** for developing hardfiles
- **hgw** for branding the product
- **acidvegas** for funding the project
## License
2023-10-01 13:43:15 -04:00
MIT