Sign inSign up

andybzn/redirectr

By andybzn

•Updated about 1 month ago

Lightweight, fast, self-hosted shortlink redirection service written in Rust

Image
Web servers
0

327

andybzn/redirectr repository overview

⁠redirectr

A lightweight, fast, self-hosted shortlink redirection service written in Rust, using Axum⁠ and Sqlx⁠ with SQLite.

Point a domain at it, mount a volume, and start creating short links backed by a single SQLite file — no external database required.

⁠Features

  • Fast HTTP 302 redirection — instant lookups backed by SQLite
  • Secure link creation — Bearer token auth with constant-time equality checks to mitigate timing attacks
  • URL scheme validation — only http:// and https:// targets are accepted
  • Configurable fallback — / redirects to a landing page or repo URL of your choice
  • Health check endpoint — probes the SQLite schema, ready for zero-downtime orchestration
  • Automatic migrations — embedded SQLx migrations run on startup
  • Multi-arch — published for linux/amd64 and linux/arm64

⁠Quick start

docker run -d \
  --name redirectr \
  -p 3333:3333 \
  -v redirectr_data:/data \
  -e ADMIN_TOKEN="your-super-secret-token" \
  -e DEFAULT_URL="https://example.com" \
  andybzn/redirectr:latest

Or with Compose:

services:
  redirectr:
    image: andybzn/redirectr:latest
    container_name: redirectr
    restart: unless-stopped
    ports:
      - "3333:3333"
    environment:
      ADMIN_TOKEN: "your-super-secret-token"
      DEFAULT_URL: "https://example.com"
    volumes:
      - redirectr_data:/data

volumes:
  redirectr_data:

The image binds SERVER_IP=0.0.0.0 and points DATABASE_URL at /data by default — just mount a volume there so links persist across restarts.

⁠Configuration

VariableRequiredDefaultDescription
ADMIN_TOKENYes—Bearer token required to create links via POST /.
SERVER_IPNo0.0.0.0 (in-image)IP address the HTTP server binds to.
SERVER_PORTNo3333TCP port the HTTP server listens on.
DATABASE_URLNosqlite:///data/redirectr.sqliteSQLite connection URL (created automatically if missing).
MAX_CONNNo9Maximum SQLite connection pool size.
DEFAULT_URLNohttps://github.com/andybzn/redirectrFallback destination for GET /.
RUST_LOGNoredirectr=debug,sqlx=warntracing subscriber log filter level.

⁠API

  • GET /{code} — 302 to the target URL, 404 if unknown
  • POST /?code=<code>&url=<target_url> — create a link (requires Authorization: Bearer <ADMIN_TOKEN>)
  • GET / — 302 to DEFAULT_URL
  • GET /health — 200 if the database is reachable, 503 otherwise

⁠Tags

  • latest — most recent build from main
  • <short-sha> — pinned build for a specific commit

⁠Source

Source, issues, and full docs: https://github.com/andybzn/redirectr⁠

Licensed under MIT.

Tag summary

Content type

Image

Digest

sha256:bef0ec6d5…

Size

2.6 MB

Last updated

about 2 months ago

docker pull andybzn/redirectr