Configuration

Snip is configured entirely through environment variables.

Environment Variables

VariableDefaultDescription
SNIP_HOST0.0.0.0Listen host address
SNIP_PORT53524Listen port number
SNIP_BASE_URLhttp://localhost:53524Public URL used in share links and API responses
SNIP_DB_PATH./data/snip.dbSQLite database file path
SNIP_ADMIN_PASSWORD(empty)Admin password for protected endpoints
SNIP_JWT_SECRET(auto-generated)JWT signing key. Set this in production!
SNIP_MAX_SIZE10485760Maximum paste size in bytes (10MB)
SNIP_ALLOW_ANONYMOUStrueAllow unauthenticated paste creation
Important: Always set SNIP_JWT_SECRET to a strong random string in production. The auto-generated secret changes on each restart, invalidating all tokens.

Configuration Examples

Minimal Production Setup

.env
SNIP_BASE_URL=https://snip.yourdomain.com
SNIP_JWT_SECRET=$(openssl rand -hex 32)

Docker Environment

docker-compose.yml
environment:
  - SNIP_BASE_URL=https://snip.yourdomain.com
  - SNIP_JWT_SECRET=your-random-32-byte-secret
  - SNIP_PORT=53524
  - SNIP_DB_PATH=/app/data/snip.db
  - SNIP_MAX_SIZE=10485760

Custom Port and Host

bash
SNIP_HOST=127.0.0.1 SNIP_PORT=8080 ./snip

Database

Snip uses SQLite with WAL (Write-Ahead Logging) mode for concurrent read access. The database file is created automatically on first run.

Schema

The database has two tables with automatic migration:

Database Indexes

IndexColumn(s)Purpose
idx_pastes_slugslugFast paste lookup by slug
idx_pastes_expiresexpires_atEfficient cleanup of expired pastes
idx_pastes_createdcreated_at DESCChronological listing
idx_tokens_hashtoken_hashFast API token lookup
idx_pastes_burnburn_after_read, viewsEfficient burn-after-read cleanup

Backup

Create a database backup via the API:

bash
curl -X POST http://localhost:53524/api/v1/backup \
  -H "Authorization: snip_your_token"

Or manually copy the database file (ensure Snip is stopped or use SQLite's backup API):

bash
cp /var/lib/snip/snip.db /backup/snip-$(date +%Y%m%d).db

Rate Limiting

Default rate limit: 120 requests per minute per IP address. Rate limiting is applied globally to all endpoints.

When exceeded, the server returns HTTP 429 (Too Many Requests).

Security Headers

Snip automatically sets these security headers on all responses:

HeaderValue
X-Content-Type-Optionsnosniff
X-Frame-OptionsDENY
Referrer-Policystrict-origin-when-cross-origin
Permissions-Policygeolocation=(), microphone=(), camera=()
Content-Security-PolicyRestricted to self + CDN sources