Deploying transfer.sh
Introduction
transfer.sh is a simple, fast, and easy-to-use file sharing service that allows you to share files from the command line. Originally created as a public service, transfer.sh can be self-hosted to provide your own private file sharing infrastructure with complete control over your data.
The service is designed with simplicity in mind - upload a file and get a link. Files can be uploaded via curl, wget, or any HTTP client, making it perfect for developers and system administrators who work primarily in the terminal.
Key highlights of transfer.sh:
- Command Line Friendly: Upload files directly from terminal using curl or wget
- Web Interface: Simple web UI for browser-based uploads
- Automatic Expiration: Files automatically expire after a configurable period
- Download Limits: Set maximum download counts for shared files
- Encryption Support: Client-side encryption for sensitive files
- No Registration: No accounts needed to share files
- Multiple Storage Backends: Support for local storage, S3, and other backends
- Custom URLs: Generate memorable URLs for shared files
- Virus Scanning: Optional ClamAV integration for security
- Rate Limiting: Protect against abuse with configurable limits
- Open Source: Fully open source and self-hostable
This guide walks through deploying transfer.sh on Klutch.sh using Docker, configuring storage, and setting up the service for production use.
Why Deploy transfer.sh on Klutch.sh
Deploying transfer.sh on Klutch.sh provides several advantages:
Simplified Deployment: Klutch.sh automatically detects your Dockerfile and builds transfer.sh without complex configuration. Push to GitHub, and your file sharing service deploys automatically.
Persistent Storage: Attach persistent volumes for uploaded files. Your shared files survive container restarts and redeployments.
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.
Private File Sharing: Control who has access to your file sharing infrastructure, perfect for teams or organizations.
Custom Domains: Assign a custom domain for branded file sharing links.
Always-On Availability: Your file sharing service remains accessible 24/7 without managing your own hardware.
Prerequisites
Before deploying transfer.sh on Klutch.sh, ensure you have:
- A Klutch.sh account
- A GitHub account with a repository for your transfer.sh configuration
- Basic familiarity with Docker and containerization concepts
- (Optional) A custom domain for your transfer.sh instance
Preparing Your Repository
To deploy transfer.sh on Klutch.sh, create a GitHub repository containing your Dockerfile.
Repository Structure
transfer-sh-deploy/├── Dockerfile└── .dockerignoreCreating the Dockerfile
Create a Dockerfile in the root of your repository:
FROM dutchcoders/transfer.sh:latest
# Set environment variablesENV LISTENER=:8080ENV BASEDIR=/dataENV TEMP_PATH=/tmp
# File retention settingsENV PURGE_DAYS=14ENV PURGE_INTERVAL=1
# Maximum file size (in bytes)ENV MAX_UPLOAD_SIZE=5368709120
# Expose the web interface portEXPOSE 8080
# Start transfer.shCMD ["--provider", "local", "--basedir", "/data"]Advanced Dockerfile with S3 Storage
For production deployments with S3-compatible storage:
FROM dutchcoders/transfer.sh:latest
# Set environment variablesENV LISTENER=:8080ENV TEMP_PATH=/tmp
# File retention settingsENV PURGE_DAYS=${PURGE_DAYS:-14}ENV PURGE_INTERVAL=1
# Maximum file size (5GB default)ENV MAX_UPLOAD_SIZE=${MAX_UPLOAD_SIZE:-5368709120}
# S3 configurationENV AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}ENV AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}ENV BUCKET=${S3_BUCKET}ENV S3_REGION=${S3_REGION}ENV S3_ENDPOINT=${S3_ENDPOINT}
# Rate limitingENV RATE_LIMIT=100
EXPOSE 8080
CMD ["--provider", "s3"]Creating the .dockerignore File
Create a .dockerignore file:
.git.github*.mdLICENSE.gitignore*.log.DS_Store.env.env.localEnvironment Variables Reference
| Variable | Required | Default | Description |
|---|---|---|---|
LISTENER | No | :8080 | Address and port to listen on |
BASEDIR | No | /data | Local storage directory |
PURGE_DAYS | No | 14 | Days before files are deleted |
PURGE_INTERVAL | No | 1 | Hours between purge runs |
MAX_UPLOAD_SIZE | No | 5GB | Maximum upload size in bytes |
RATE_LIMIT | No | - | Requests per minute limit |
AWS_ACCESS_KEY_ID | Conditional | - | S3 access key (for S3 storage) |
AWS_SECRET_ACCESS_KEY | Conditional | - | S3 secret key (for S3 storage) |
BUCKET | Conditional | - | S3 bucket name |
S3_REGION | Conditional | - | S3 region |
Deploying transfer.sh on Klutch.sh
Once your repository is prepared, follow these steps to deploy transfer.sh:
- Select HTTP as the traffic type
- Set the internal port to 8080
- Detect your Dockerfile automatically
- Build the container image
- Attach the persistent volumes
- Start the transfer.sh container
- Provision an HTTPS certificate
Push Your Repository to GitHub
Initialize your repository and push to GitHub. Ensure your Dockerfile is in the root of your repository.
Create a New Project on Klutch.sh
Navigate to the Klutch.sh dashboard and create a new project. Give it a descriptive name like “transfer-sh” or “file-share”.
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 transfer.sh Dockerfile.
Configure HTTP Traffic
transfer.sh serves its interface over HTTP. In the deployment settings:
Set Environment Variables
In the environment variables section, configure your desired settings:
| Variable | Value |
|---|---|
PURGE_DAYS | 14 (or your preferred retention period) |
MAX_UPLOAD_SIZE | 5368709120 (5GB, adjust as needed) |
Attach Persistent Volumes
Add the following volume for local storage:
| Mount Path | Recommended Size | Purpose |
|---|---|---|
/data | 50+ GB | Uploaded files storage |
/tmp | 10 GB | Temporary upload storage |
Deploy Your Application
Click Deploy to start the build process. Klutch.sh will:
Access transfer.sh
Once deployment completes, access your transfer.sh instance at https://your-app-name.klutch.sh.
Using transfer.sh
Command Line Usage
Upload files using curl:
# Upload a filecurl --upload-file ./example.txt https://your-app-name.klutch.sh/example.txt
# Upload with a custom filenamecurl --upload-file ./document.pdf https://your-app-name.klutch.sh/my-document.pdf
# Upload and set max downloadscurl --upload-file ./secret.txt -H "Max-Downloads: 1" https://your-app-name.klutch.sh/secret.txt
# Upload and set expiration (in days)curl --upload-file ./temp.txt -H "Max-Days: 1" https://your-app-name.klutch.sh/temp.txtUsing wget
# Upload with wgetwget --method PUT --body-file=./example.txt https://your-app-name.klutch.sh/example.txt -O - -qWeb Interface
Access the web interface in your browser:
- Navigate to
https://your-app-name.klutch.sh - Drag and drop files or click to select
- Copy the generated link
Shell Aliases
Add convenient aliases to your shell configuration:
# Add to ~/.bashrc or ~/.zshrctransfer() { curl --progress-bar --upload-file "$1" "https://your-app-name.klutch.sh/$(basename "$1")" | tee /dev/null}
# Usage: transfer myfile.txtEncrypted Uploads
For sensitive files, encrypt before uploading:
# Encrypt and uploadcat secret.txt | gpg -ac -o- | curl -X PUT --upload-file "-" https://your-app-name.klutch.sh/secret.txt.gpg
# Download and decryptcurl https://your-app-name.klutch.sh/abc123/secret.txt.gpg | gpg -o- > secret.txtAdvanced Configuration
Download Limits
Control how many times a file can be downloaded:
curl --upload-file ./file.txt -H "Max-Downloads: 5" https://your-app-name.klutch.sh/file.txtCustom Expiration
Set per-file expiration:
curl --upload-file ./file.txt -H "Max-Days: 7" https://your-app-name.klutch.sh/file.txtCombining Options
Apply multiple restrictions:
curl --upload-file ./sensitive.txt \ -H "Max-Downloads: 1" \ -H "Max-Days: 1" \ https://your-app-name.klutch.sh/sensitive.txtProduction Best Practices
Security Recommendations
- Rate Limiting: Enable rate limiting to prevent abuse
- File Size Limits: Set appropriate maximum file sizes
- Encryption: Encourage client-side encryption for sensitive files
- Monitoring: Monitor disk usage and upload patterns
Storage Management
- Purge Settings: Configure appropriate retention periods
- Volume Sizing: Allocate sufficient storage for your usage patterns
- S3 Storage: Consider S3-compatible storage for scalability
Abuse Prevention
- Rate Limiting: Implement rate limits per IP
- File Type Restrictions: Consider restricting dangerous file types
- Monitoring: Watch for unusual upload patterns
Troubleshooting Common Issues
Uploads Failing
Symptoms: curl returns errors when uploading.
Solutions:
- Check file size against
MAX_UPLOAD_SIZE - Verify sufficient disk space
- Check deployment logs for errors
Files Not Accessible
Symptoms: Download links return 404 errors.
Solutions:
- Verify the file hasn’t expired
- Check download count limits
- Confirm persistent volume is mounted correctly
Slow Uploads
Symptoms: Upload speeds are very slow.
Solutions:
- Check available bandwidth
- Verify sufficient resources allocated
- Consider using S3 storage for larger files
Additional Resources
- transfer.sh GitHub Repository
- Official transfer.sh Service
- Klutch.sh Persistent Volumes
- Klutch.sh Deployments
Conclusion
Deploying transfer.sh on Klutch.sh gives you a simple, powerful file sharing service with automatic builds, persistent storage, and secure HTTPS access. The command-line friendly design makes it perfect for developers and system administrators who need quick, easy file sharing without the complexity of full-featured cloud storage.
Whether you’re sharing configuration files with teammates, distributing builds, or just need a quick way to move files between systems, transfer.sh on Klutch.sh provides a reliable, self-hosted solution that you control completely.