Skip to content

Deploying rustypaste

Introduction

rustypaste is a minimal file upload and pastebin service written in Rust. Designed to be fast, simple, and self-hosted, rustypaste allows you to share files and text snippets via simple HTTP requests without complex interfaces or dependencies.

Built with Rust’s performance and reliability, rustypaste provides essential file sharing functionality with configurable expiration, size limits, and duplicate detection. The service is perfect for developers who need a quick way to share files and code snippets without relying on third-party services.

Key highlights of rustypaste:

  • Minimal Design: Simple HTTP API for uploading and retrieving files
  • Fast Performance: Written in Rust for low latency responses
  • Expiring Uploads: Configure automatic expiration for uploads
  • Duplicate Detection: Optional deduplication of identical files
  • File Size Limits: Configurable maximum file sizes
  • Syntax Highlighting: Automatic highlighting for code pastes
  • URL Shortening: Generate short URLs for shared content
  • One-Shot URLs: Links that expire after a single view
  • Random URLs: Configurable random URL generation
  • No JavaScript Required: Works with curl and simple HTTP clients
  • Authentication: Optional token-based authentication
  • Open Source: Licensed under MIT

This guide walks through deploying rustypaste on Klutch.sh using Docker, configuring the service, and setting up for production use.

Why Deploy rustypaste on Klutch.sh

Deploying rustypaste on Klutch.sh provides several advantages for file sharing:

Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds rustypaste without complex orchestration. Push to GitHub, and your pastebin deploys automatically.

Persistent Storage: Attach persistent volumes for uploaded files. Your shared content survives container restarts.

HTTPS by Default: Klutch.sh provides automatic SSL certificates, ensuring secure file transfers.

GitHub Integration: Connect your configuration repository directly from GitHub. Updates trigger automatic redeployments.

Scalable Resources: rustypaste is lightweight but can scale for larger storage needs.

Custom Domains: Assign a custom domain for branded, memorable share URLs.

Always-On Availability: Your file sharing service runs 24/7.

Prerequisites

Before deploying rustypaste on Klutch.sh, ensure you have:

  • A Klutch.sh account
  • A GitHub account with a repository for your rustypaste configuration
  • Basic familiarity with Docker and command-line tools
  • (Optional) A custom domain for your rustypaste instance

Understanding rustypaste Architecture

rustypaste is designed for simplicity:

Rust Binary: A single binary handles HTTP requests, file storage, and URL generation.

File-Based Storage: Uploaded files are stored directly on the filesystem.

Configuration File: TOML configuration for customizing behavior.

No Database: Simple operation without database dependencies.

Preparing Your Repository

To deploy rustypaste on Klutch.sh, create a GitHub repository containing your Dockerfile and configuration.

Repository Structure

rustypaste-deploy/
├── Dockerfile
├── config.toml
├── .dockerignore
└── README.md

Creating the Dockerfile

Create a Dockerfile in the root of your repository:

FROM orhunp/rustypaste:latest
# Copy configuration
COPY config.toml /config.toml
# Create upload directory
RUN mkdir -p /uploads
# Environment variable for config path
ENV CONFIG=/config.toml
# Expose the web port
EXPOSE 8000

Creating the Configuration File

Create a config.toml file:

[server]
address = "0.0.0.0:8000"
max_content_length = "10MB"
upload_path = "/uploads"
[paste]
# Random URL length
random_url = { enabled = true, words = 3, separator = "-" }
# Or use: random_url = { type = "alphanumeric", length = 8 }
# Default expiration
default_extension = "txt"
# Enable duplicate file detection
duplicate_files = { enabled = true }
# File expiration
delete_expired_files = { enabled = true, interval = "1h" }
[landing_page]
text = """
Welcome to rustypaste!
Upload files with:
curl -F 'file=@example.txt' {server_url}
Upload from stdin:
echo 'Hello World' | curl -F 'file=@-' {server_url}
Set expiration:
curl -F 'file=@example.txt' -H 'expire:1h' {server_url}
"""
# Optional authentication
# [server.auth]
# tokens = ["your-secret-token"]

Creating the .dockerignore File

Create a .dockerignore file:

.git
.github
*.md
LICENSE
.gitignore
*.log
.DS_Store

Environment Variables Reference

VariableRequiredDefaultDescription
CONFIGNoconfig.tomlPath to configuration file
RUST_LOGNoinfoLogging level

Deploying rustypaste on Klutch.sh

Once your repository is prepared, follow these steps to deploy rustypaste:

    Push Your Repository to GitHub

    Initialize your repository and push to GitHub:

    Terminal window
    git init
    git add Dockerfile config.toml .dockerignore README.md
    git commit -m "Initial rustypaste deployment configuration"
    git remote add origin https://github.com/yourusername/rustypaste-deploy.git
    git push -u origin main

    Create a New Project on Klutch.sh

    Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “rustypaste” or “pastebin”.

    Create a New App

    Within your project, create a new app. Connect your GitHub account if you haven’t already, then select the repository containing your rustypaste Dockerfile.

    Configure HTTP Traffic

    In the deployment settings:

    • Select HTTP as the traffic type
    • Set the internal port to 8000

    Set Environment Variables

    In the environment variables section, add:

    VariableValue
    CONFIG/config.toml
    RUST_LOGinfo

    Attach Persistent Volumes

    Add the following volume for file storage:

    Mount PathRecommended SizePurpose
    /uploads50 GBUploaded files and pastes

    Deploy Your Application

    Click Deploy to start the build process. Klutch.sh will:

    • Detect your Dockerfile automatically
    • Build the container with your configuration
    • Attach the persistent volumes
    • Start the rustypaste container
    • Provision an HTTPS certificate

    Access rustypaste

    Once deployment completes, access your rustypaste instance at https://your-app-name.klutch.sh. The landing page displays usage instructions.

Using rustypaste

Uploading Files

Upload a file using curl:

Terminal window
curl -F 'file=@document.pdf' https://your-paste-domain.klutch.sh

Response:

https://your-paste-domain.klutch.sh/abc-def-ghi.pdf

Uploading Text

Paste text from stdin:

Terminal window
echo "Hello, World!" | curl -F 'file=@-' https://your-paste-domain.klutch.sh

Or pipe command output:

Terminal window
cat script.py | curl -F 'file=@-;filename=script.py' https://your-paste-domain.klutch.sh

Setting Expiration

Specify when uploads should expire:

Terminal window
# Expire in 1 hour
curl -F 'file=@temp.txt' -H 'expire:1h' https://your-paste-domain.klutch.sh
# Expire in 7 days
curl -F 'file=@temp.txt' -H 'expire:7d' https://your-paste-domain.klutch.sh

One-Shot URLs

Create links that expire after one view:

Terminal window
curl -F 'file=@secret.txt' -H 'oneshot:true' https://your-paste-domain.klutch.sh

Custom Filenames

Specify the output filename:

Terminal window
curl -F 'file=@data.json;filename=custom-name.json' https://your-paste-domain.klutch.sh

Authenticated Uploads

If authentication is enabled:

Terminal window
curl -F 'file=@document.pdf' -H 'Authorization: your-secret-token' https://your-paste-domain.klutch.sh

Configuration Options

URL Generation

Configure random URL format in config.toml:

# Word-based URLs (human-readable)
random_url = { enabled = true, words = 3, separator = "-" }
# Alphanumeric URLs
random_url = { type = "alphanumeric", length = 8 }
# Petname-style URLs
random_url = { type = "petname", words = 2, separator = "_" }

File Expiration

Configure automatic cleanup:

[paste]
# Check for expired files every hour
delete_expired_files = { enabled = true, interval = "1h" }

Size Limits

Set maximum upload sizes:

[server]
max_content_length = "100MB" # Maximum file size

Production Best Practices

Security Recommendations

  • Authentication: Enable token authentication for controlled access
  • Size Limits: Set appropriate file size limits
  • Expiration: Configure default expiration to manage storage
  • HTTPS Only: All connections should use HTTPS (provided by Klutch.sh)

Storage Management

  • Monitor Usage: Track storage consumption
  • Expiration Policies: Use expiration to automatically clean old files
  • Duplicate Detection: Enable to reduce storage usage

Backup Strategy

  1. File Backup: Periodically back up the /uploads directory
  2. Configuration Backup: Keep config.toml in version control

Troubleshooting Common Issues

Upload Failures

Symptoms: curl returns an error when uploading.

Solutions:

  • Check file size against max_content_length
  • Verify authentication token if required
  • Ensure sufficient disk space

Files Not Accessible

Symptoms: Uploaded file URLs return 404.

Solutions:

  • Verify file wasn’t deleted by expiration
  • Check upload_path configuration
  • Ensure volume is properly mounted

Expiration Not Working

Symptoms: Old files aren’t being cleaned up.

Solutions:

  • Verify delete_expired_files is enabled
  • Check interval configuration
  • Review logs for cleanup errors

Additional Resources

Conclusion

Deploying rustypaste on Klutch.sh gives you a fast, minimal file sharing service with automatic builds, persistent storage, and secure HTTPS access. The combination of rustypaste’s simplicity and Klutch.sh’s deployment ease means you can share files instantly without complex infrastructure.

With expiring uploads, duplicate detection, and one-shot URLs, rustypaste provides essential pastebin functionality while respecting privacy. The command-line friendly interface makes it perfect for developer workflows.

Whether you’re sharing code snippets, transferring files, or running a private pastebin, rustypaste on Klutch.sh delivers reliable, self-hosted file sharing.