Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

Config File

url2ref-web/config.toml:

[default]
address = "127.0.0.1"
port = 8000

[release]
address = "0.0.0.0"
log_level = "critical"

Environment Variables

VariableDescriptionDefault
ROCKET_ADDRESSBind address127.0.0.1
ROCKET_PORTPort8000
ROCKET_LOG_LEVELoff, critical, normal, debugnormal
DEEPL_API_KEYDeepL translation—
GOOGLE_TRANSLATE_API_KEYGoogle translation—
export ROCKET_ADDRESS="0.0.0.0"
export ROCKET_PORT="3000"
cargo run --bin url2ref-web

TLS

[default.tls]
certs = "/path/to/cert.pem"
key = "/path/to/key.pem"

Or use a reverse proxy (nginx, Caddy) in production.

For production deployments, consider adding rate limiting via a reverse proxy:

# nginx rate limiting
limit_req_zone $binary_remote_addr zone=url2ref:10m rate=10r/s;

server {
    location /api/ {
        limit_req zone=url2ref burst=20 nodelay;
        proxy_pass http://127.0.0.1:8000;
    }
}

Docker Configuration

When running in Docker, use environment variables:

# docker-compose.yml
services:
  url2ref-web:
    build: .
    ports:
      - "8000:8000"
    environment:
      - ROCKET_ADDRESS=0.0.0.0
      - ROCKET_PORT=8000
      - ROCKET_LOG_LEVEL=normal
      - DEEPL_API_KEY=${DEEPL_API_KEY}

Health Checks

The server responds to requests at the root path. For health checks:

curl -f http://localhost:8000/ || exit 1

Or add a dedicated health endpoint (requires code modification).

Monitoring

Logging

Logs are written to stderr. Redirect for persistence:

cargo run --bin url2ref-web 2>&1 | tee -a url2ref.log

Log Levels

LevelDescription
offNo logging
criticalOnly critical errors
normalStandard logging
debugVerbose debugging

Production Checklist

Before deploying to production:

  • Set ROCKET_PROFILE=release
  • Bind to 0.0.0.0 if using containers
  • Configure TLS (directly or via reverse proxy)
  • Set appropriate log level
  • Configure API keys securely (not in code)
  • Set up rate limiting
  • Enable static file caching
  • Configure health checks
  • Set up log rotation

Next Steps