Scratchbox Pastebin
Scratchbox is a minimal self-hosted pastebin service written in Go. It is intentionally unauthenticated and optimized for temporary sharing of text or small files with an expiration time.
Each upload creates exactly one scratch. For multi-file sharing, bundle files into an archive (for example .zip or .tar.gz) and upload that single archive file.
Scratch content is stored on disk gzip-compressed transparently to reduce filesystem usage; API/UI reads return original uncompressed content.
Quick Start
- Copy the sample config:
cp config.example.yaml config.yaml
- Adjust settings for your environment.
- Start the server:
go run ./cmd/pastebin -config config.yaml
- Open:
http://127.0.0.1:8080/
Without -config, built-in defaults are used.
Configuration
All configuration is YAML.
server
listen_addr: address for the HTTP server (required).- Default:
:8080
- Default:
limits
max_upload_size: max request body size for uploads.- Examples:
5MB,100MB,1GiB - Default:
100MB
- Examples:
default_ttl: expiration applied to new scratches.- Must be
> 0and<= 24h - Default:
1h
- Must be
storage
data_dir: directory for scratch files and metadata index.- Default:
./data
- Default:
cleanup_interval: background interval for deleting expired content.- Must be at least
10s - Default:
1m
- Must be at least
security
allowed_ips: optional list of IPs and CIDRs allowed to create scratches.- Applies to write route only:
POST /api/scratch - Empty list means no allowlist restriction
- Applies to write route only:
trust_proxy_headers: iftrue, client IP extraction honorsX-Forwarded-ForthenX-Real-IP.- Keep
falseunless behind a trusted reverse proxy that sets these headers.
- Keep
rate_limit.enabled: enable per-IP token-bucket rate limiting on write route.- Default:
true
- Default:
rate_limit.requests_per_minute: steady refill rate per client IP.- Must be
> 0 - Default:
30
- Must be
rate_limit.burst: immediate burst capacity per client IP.- Must be
> 0 - Default:
10
- Must be
Security Posture
This service is intentionally unauthenticated. Anyone with network access can read scratches, and (unless restricted) create scratches.
- No authentication, user accounts, or moderation controls.
- No malware scanning.
- Abuse controls are limited to upload size limits, TTL expiration, optional IP allowlisting, and write-route rate limiting.
- Treat this as a convenience utility, not a hardened internet-facing platform.
LAN Deployment Notes
For home/lab/LAN-only use:
- Bind to a private address, for example
127.0.0.1:8080(single host) or192.168.x.x:8080. - Use
allowed_ipsto restrict write access to trusted subnets. - Keep
max_upload_sizeanddefault_ttlsmall. - Keep
trust_proxy_headersdisabled unless using a trusted reverse proxy.
Public Deployment Notes
If exposed beyond a trusted LAN, place a reverse proxy in front (Nginx, Caddy, Traefik, etc.) and add external controls:
- TLS termination and strict transport settings.
- Additional request filtering/WAF controls.
- Stronger rate limits at the edge.
- Optional network-level restrictions to write route.
- Monitoring and log retention suitable for abuse triage.
Recommended baseline: run behind a reverse proxy, keep low TTL and size limits, and use allowed_ips for write access whenever possible.