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.mdCreating the Dockerfile
Create a Dockerfile in the root of your repository:
FROM orhunp/rustypaste:latest
# Copy configurationCOPY config.toml /config.toml
# Create upload directoryRUN mkdir -p /uploads
# Environment variable for config pathENV CONFIG=/config.toml
# Expose the web portEXPOSE 8000Creating 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 lengthrandom_url = { enabled = true, words = 3, separator = "-" }# Or use: random_url = { type = "alphanumeric", length = 8 }
# Default expirationdefault_extension = "txt"
# Enable duplicate file detectionduplicate_files = { enabled = true }
# File expirationdelete_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*.mdLICENSE.gitignore*.log.DS_StoreEnvironment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
CONFIG | No | config.toml | Path to configuration file |
RUST_LOG | No | info | Logging level |
Deploying rustypaste on Klutch.sh
Once your repository is prepared, follow these steps to deploy rustypaste:
- Select HTTP as the traffic type
- Set the internal port to 8000
- Detect your Dockerfile automatically
- Build the container with your configuration
- Attach the persistent volumes
- Start the rustypaste container
- Provision an HTTPS certificate
Push Your Repository to GitHub
Initialize your repository and push to GitHub:
git initgit add Dockerfile config.toml .dockerignore README.mdgit commit -m "Initial rustypaste deployment configuration"git remote add origin https://github.com/yourusername/rustypaste-deploy.gitgit push -u origin mainCreate 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:
Set Environment Variables
In the environment variables section, add:
| Variable | Value |
|---|---|
CONFIG | /config.toml |
RUST_LOG | info |
Attach Persistent Volumes
Add the following volume for file storage:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/uploads | 50 GB | Uploaded files and pastes |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
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:
curl -F 'file=@document.pdf' https://your-paste-domain.klutch.shResponse:
https://your-paste-domain.klutch.sh/abc-def-ghi.pdfUploading Text
Paste text from stdin:
echo "Hello, World!" | curl -F 'file=@-' https://your-paste-domain.klutch.shOr pipe command output:
cat script.py | curl -F 'file=@-;filename=script.py' https://your-paste-domain.klutch.shSetting Expiration
Specify when uploads should expire:
# Expire in 1 hourcurl -F 'file=@temp.txt' -H 'expire:1h' https://your-paste-domain.klutch.sh
# Expire in 7 dayscurl -F 'file=@temp.txt' -H 'expire:7d' https://your-paste-domain.klutch.shOne-Shot URLs
Create links that expire after one view:
curl -F 'file=@secret.txt' -H 'oneshot:true' https://your-paste-domain.klutch.shCustom Filenames
Specify the output filename:
curl -F 'file=@data.json;filename=custom-name.json' https://your-paste-domain.klutch.shAuthenticated Uploads
If authentication is enabled:
curl -F 'file=@document.pdf' -H 'Authorization: your-secret-token' https://your-paste-domain.klutch.shConfiguration Options
URL Generation
Configure random URL format in config.toml:
# Word-based URLs (human-readable)random_url = { enabled = true, words = 3, separator = "-" }
# Alphanumeric URLsrandom_url = { type = "alphanumeric", length = 8 }
# Petname-style URLsrandom_url = { type = "petname", words = 2, separator = "_" }File Expiration
Configure automatic cleanup:
[paste]# Check for expired files every hourdelete_expired_files = { enabled = true, interval = "1h" }Size Limits
Set maximum upload sizes:
[server]max_content_length = "100MB" # Maximum file sizeProduction 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
- File Backup: Periodically back up the
/uploadsdirectory - 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
- rustypaste GitHub Repository
- rustypaste Documentation
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
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.