RPS (Rust Paste Server) - A lightweight, ultra-fast self-hosted pastebin server. Built with a high-performance Rust backend and a zero-framework, minimalist frontend UI.
RPS provides a sleek, zero-bloat platform for sharing text and code snippets. It is designed to run entirely self-contained with no external font or library CDN dependencies.
The server uses an asynchronous Axum/Tokio stack backed by PostgreSQL, ensuring extremely low resource usage and sub-millisecond response times. The client-side single page application (SPA) handles rendering, saving, duplication, and syntax highlighting dynamically.
Local config reference: config.toml.
- Minimalist UI: Simple, fast aesthetic with responsive transitions, dynamic scroll indicators.
- Dynamic Syntax Highlighting: Automatic detection and loading of Highlight.js libraries for code extensions, only downloaded when viewing a non-plaintext file.
- SPA Path-Based Extensions: Accessing
/{PASTE_ID}.rsor/{PASTE_ID}.jsdirectly loads the syntax-highlighted code. - Duplicate & Edit Flow: Clone any existing paste into the editor context with a single click to make updates and save a new version.
- Accidental Loss Prevention: Prompts for confirmation when initiating a new paste if the current editor contains unsaved modifications.
- IP Rate Limiting: Embedded middleware tracking request frequencies per IP to prevent spamming and DoS attempts.
- Optimized Caching & Compression: Automatic Gzip/Brotli file compression via tower-http and cache-control headers on static assets.
- Command Line Client: A minimalist CLI helper (curl-based or native) to allow saving directly from the terminal.
- Password Protection: Optional encryption or password validation before loading sensitive snippets.
- Admin Dashboard: A panel to monitor active pastes, storage limits, and server metrics.
- Backend: Rust (Axum, Tokio, SQLx, Postgres)
- Frontend: HTML5, CSS3 (Vanilla), JavaScript (ES6+ Vanilla)
- Database: PostgreSQL
- Containerization: Docker, Docker Compose
git clone https://github.com/tristanbudd/RPS.git
cd RPS-
Environment Variables (.env): Copy the example environment file and configure secure database credentials:
cp .env.example .env
Open the
.envfile and set a custom username (DB_USERNAME) and a strong, randomly generated password (DB_PASSWORD). -
Application Configuration (
config.toml): A configuration file is provided inconfig.toml. You can edit it to customize settings like the server host, port, maximum paste length limits, and cleanup task intervals:[server] host = "0.0.0.0" port = 8000 [paste] default_expiry_days = 30 max_length = 5000000
[!NOTE] The server will prioritize environment variables (like
DATABASE_URL, constructed from the.envfile in the Docker Compose environment) over the database settings inconfig.toml. -
Database Port Security: By default, the database port
5432is not exposed to the public internet or host. If you need to connect to the database from the host machine for local development or administration, you can uncomment the loopback port binding indocker-compose.yml:ports: - "127.0.0.1:5432:5432"
Build the application and start both the PostgreSQL database and the web server:
docker compose up -d --buildThe server will be accessible locally at http://localhost:18000.
cargo build --release # Build the production release binary locally
cargo test # Run the test suite
cargo fmt --all # Format the codebase according to style rules
cargo clippy # Run the linter to analyze and improve code quality- Static Asset Serving: The directory
src/staticcontains the SPA bundle and the local font assets. - Database Schema: The database tables are automatically initialized and migrated by the application on startup (defined in
src/main.rs). - SPA Fallback: The server uses a custom fallback handler to serve
index.htmlwith a200 OKstatus for SPA routes, avoiding console errors when utilizing file extensions.
This project bundles and hosts the following open-source assets locally:
-
- Creator: Rasmus Andersson
- License: SIL Open Font License 1.1
- Usage: Used as the primary user interface typeface.
-
- Creator: Microsoft
- License: SIL Open Font License 1.1
- Usage: Used as the monospaced font for code editing and rendering.
-
- License: BSD 3-Clause License
- Usage: Handles client-side code syntax highlighting dynamically.
