基于Worker的在线剪贴板和文件分享服务,支持 Markdown、阅后即焚、文本/大文件分享、密码保护等功能,支持多种部署方式,可作为WebDav挂载
📸 Showcase • ✨ Features • 🚀 Deployment Guide • 🔧 Tech Stack • 💻 Development • 📄 License
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Before starting deployment, please ensure you have prepared the following:
S3_ACCESS_KEY_ID
S3_SECRET_ACCESS_KEY
S3_BUCKET_NAME
S3_ENDPOINT
Using GitHub Actions enables automatic deployment of the application after code is pushed.
Secret Name | Required | Purpose |
---|---|---|
CLOUDFLARE_API_TOKEN |
✅ | Cloudflare API token (requires Workers, D1, and Pages permissions) |
CLOUDFLARE_ACCOUNT_ID |
✅ | Cloudflare account ID |
ENCRYPTION_SECRET |
❌ | Key for encrypting sensitive data (if not provided, one will be automatically generated) |
Visit Cloudflare Dashboard
Create a new API token
Select the “Edit Cloudflare Workers” template, and add D1 database edit permission
Fork the repository, fill in the secrets, and then run the workflow!!!
Deployment is automatically triggered whenever files in the backend
directory are changed and pushed to the main
or master
branch. The workflow proceeds as follows:
⚠️ Remember your backend domain name
Fork the repository, fill in the secrets, and then run the workflow.
Deployment is automatically triggered whenever files in the frontend
directory are changed and pushed to the main
or master
branch. After deployment, you need to set environment variables in the Cloudflare Pages control panel:
Log in to Cloudflare Dashboard
Navigate to Pages → Your project (e.g., “cloudpaste-frontend”)
Click “Settings” → “Environment variables”
Add environment variable:
Name: VITE_BACKEND_URL
Value: Your backend Worker URL (e.g., https://cloudpaste-backend.your-username.workers.dev
) without trailing “/”. It is recommended to use a custom worker backend domain.
Make sure to enter the complete backend domain name in “https://xxxx.com” format
Important step: Then run the frontend workflow again to complete loading the backend domain!!!
Please follow the steps strictly, otherwise the backend domain loading will fail
For Vercel, it’s recommended to deploy as follows:
Framework Preset: Vite
Build Command: npm run build
Output Directory: dist
Install Command: npm install
☝️ Choose one of the above methods
git clone https://github.com/ling-drag0n/CloudPaste.git
cd CloudPaste/backend
Install dependencies
npm install
Log in to Cloudflare
npx wrangler login
Create D1 database
npx wrangler d1 create cloudpaste-db
Note the database ID from the output.
Modify wrangler.toml configuration
[[d1_databases]]
binding = "DB"
database_name = "cloudpaste-db"
database_id = "YOUR_DATABASE_ID"
Deploy Worker
npx wrangler deploy
Note the URL from the output; this is your backend API address.
Initialize database (automatic)
Visit your Worker URL to trigger initialization:
https://cloudpaste-backend.your-username.workers.dev
⚠️ Security reminder: Please change the default administrator password immediately after system initialization (Username: admin, Password: admin123).
Prepare frontend code
cd CloudPaste/frontend
npm install
Configure environment variables
Create or modify the .env.production
file:
VITE_BACKEND_URL=https://cloudpaste-backend.your-username.workers.dev
VITE_APP_ENV=production
VITE_ENABLE_DEVTOOLS=false
Build frontend project
npm run build
Deploy to Cloudflare Pages
Method 1: Via Wrangler CLI
npx wrangler pages deploy dist --project-name=cloudpaste-frontend
Method 2: Via Cloudflare Dashboard
dist
directoryPrepare frontend code
cd CloudPaste/frontend
npm install
Install and log in to Vercel CLI
npm install -g vercel
vercel login
Configure environment variables, same as for Cloudflare Pages
Build and deploy
vercel --prod
Follow the prompts to configure the project.
CloudPaste backend can be quickly deployed using the official Docker image.
Create data storage directory
mkdir -p sql_data
Run the backend container
docker run -d --name cloudpaste-backend \
-p 8787:8787 \
-v $(pwd)/sql_data:/data \
-e ENCRYPTION_SECRET=your-encryption-key \
-e NODE_ENV=production \
-e RUNTIME_ENV=docker \
dragon730/cloudpaste-backend:latest
Note the deployment URL (e.g., http://your-server-ip:8787
), which will be needed for the frontend deployment.
⚠️ Security tip: Be sure to customize ENCRYPTION_SECRET and keep it safe, as this key is used to encrypt sensitive data.
The frontend uses Nginx to serve and configures the backend API address at startup.
docker run -d --name cloudpaste-frontend \
-p 80:80 \
-e BACKEND_URL=http://your-server-ip:8787 \
dragon730/cloudpaste-frontend:latest
⚠️ Note: BACKEND_URL must include the complete URL (including protocol http:// or https://)
⚠️ Security reminder: Please change the default administrator password immediately after system initialization (Username: admin, Password: admin123).
When a new version of the project is released, you can update your Docker deployment following these steps:
Pull the latest images
docker pull dragon730/cloudpaste-backend:latest
docker pull dragon730/cloudpaste-frontend:latest
Stop and remove old containers
docker stop cloudpaste-backend cloudpaste-frontend
docker rm cloudpaste-backend cloudpaste-frontend
Start new containers using the same run commands as above (preserving data directory and configuration)
Using Docker Compose allows you to deploy both frontend and backend services with one click, which is the simplest recommended method.
docker-compose.yml
fileversion: "3.8"
services:
frontend:
image: dragon730/cloudpaste-frontend:latest
environment:
- BACKEND_URL=https://xxx.com # Fill in the backend service address
ports:
- "8080:80" #"127.0.0.1:8080:80"
depends_on:
- backend # Depends on backend service
networks:
- cloudpaste-network
restart: unless-stopped
backend:
image: dragon730/cloudpaste-backend:latest
environment:
- NODE_ENV=production
- RUNTIME_ENV=docker
- PORT=8787
- ENCRYPTION_SECRET=custom-key # Please modify this to your own security key
volumes:
- ./sql_data:/data # Data persistence
ports:
- "8787:8787" #"127.0.0.1:8787:8787"
networks:
- cloudpaste-network
restart: unless-stopped
networks:
cloudpaste-network:
driver: bridge
docker-compose up -d
⚠️ Security reminder: Please change the default administrator password immediately after system initialization (Username: admin, Password: admin123).
Frontend: http://your-server-ip:80
Backend: http://your-server-ip:8787
When you need to update to a new version:
Pull the latest images
docker-compose pull
Recreate containers using new images (preserving data volumes)
docker-compose up -d --force-recreate
💡 Tip: If there are configuration changes, you may need to backup data and modify the docker-compose.yml file
server {
listen 443 ssl;
server_name paste.yourdomain.com; # Replace with your domain name
# SSL certificate configuration
ssl_certificate /path/to/cert.pem; # Replace with certificate path
ssl_certificate_key /path/to/key.pem; # Replace with key path
# Frontend proxy configuration
location / {
proxy_pass http://localhost:80; # Docker frontend service address
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
# Backend API proxy configuration
location /api {
proxy_pass http://localhost:8787; # Docker backend service address
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
client_max_body_size 0;
# WebSocket support (if needed)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# WebDAV Configuration
location /dav {
proxy_pass http://localhost:8787/dav; # Points to your backend service
# WebDAV necessary headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebDAV method support
proxy_pass_request_headers on;
# Support all WebDAV methods
proxy_method $request_method;
# Necessary header processing
proxy_set_header Destination $http_destination;
proxy_set_header Overwrite $http_overwrite;
# Handle large files
client_max_body_size 0;
# Timeout settings
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
}
}
⚠️ Security tip: It is recommended to configure HTTPS and a reverse proxy (such as Nginx) to enhance security.
Log in to Cloudflare Dashboard
Click R2 Storage and create a bucket.
Create API token
Save all data after creation; you’ll need it later
Configure cross-origin rules: click the corresponding bucket, click Settings, edit CORS policy as shown below:
[
{
"AllowedOrigins": ["http://localhost:3000", "https://replace-with-your-frontend-domain"],
"AllowedMethods": ["GET", "PUT", "POST", "DELETE", "HEAD"],
"AllowedHeaders": ["*"],
"ExposeHeaders": ["ETag"],
"MaxAgeSeconds": 3600
}
]
If you don’t have a B2 account, register one first, then create a bucket.
Click Application Key in the sidebar, click Create Key, and follow the illustration.
Configure B2 cross-origin; B2 cross-origin configuration is more complex, take note
You can try options 1 or 2 first, go to the upload page and see if you can upload. If F12 console shows cross-origin errors, use option 3. For a permanent solution, use option 3 directly.
Regarding option 3 configuration, since the panel cannot configure it, you need to configure manually by downloading B2 CLI tool. For more details, refer to: “https://docs.cloudreve.org/use/policy/s3#backblaze-b2”.
After downloading, in the corresponding download directory CMD, enter the following commands:
b2.exe account authorize //Log in to your account, following prompts to enter your keyID and applicationKey
b2.exe bucket get <bucketName> //You can execute to get bucket information, replace <bucketName> with your bucket name
Windows configuration, Use “.\b2-windows.exe xxx”,
Python CLI would be similar:
b2.exe bucket update <bucketName> allPrivate --cors-rules "[{\"corsRuleName\":\"CloudPaste\",\"allowedOrigins\":[\"*\"],\"allowedHeaders\":[\"*\"],\"allowedOperations\":[\"b2_upload_file\",\"b2_download_file_by_name\",\"b2_download_file_by_id\",\"s3_head\",\"s3_get\",\"s3_put\",\"s3_post\",\"s3_delete\"],\"exposeHeaders\":[\"Etag\",\"content-length\",\"content-type\",\"x-bz-content-sha1\"],\"maxAgeSeconds\":3600}]"
Replace
CloudPaste provides simple WebDAV protocol support, allowing you to mount storage spaces as network drives for convenient access and management of files directly through file managers.
https://your-backend-domain/dav
Use administrator account and password to directly access the WebDAV service:
For a more secure access method, it is recommended to create a dedicated API key:
If using NGINX as a reverse proxy, specific WebDAV configuration needs to be added to ensure all WebDAV methods work properly:
# WebDAV Configuration
location /dav {
proxy_pass http://localhost:8787; # Points to your backend service
# WebDAV necessary headers
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# WebDAV method support
proxy_pass_request_headers on;
# Support all WebDAV methods
proxy_method $request_method;
# Necessary header processing
proxy_set_header Destination $http_destination;
proxy_set_header Overwrite $http_overwrite;
# Handle large files
client_max_body_size 0;
# Timeout settings
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
}
Connection Problems:
Permission Errors:
⚠️⚠️ WebDAV Upload Issues:
Server Direct File Upload API Documentation - Detailed description of the server direct file upload interface
Clone project repository
git clone https://github.com/ling-drag0n/cloudpaste.git
cd cloudpaste
Backend setup
cd backend
npm install
# Initialize D1 database
wrangler d1 create cloudpaste-db
wrangler d1 execute cloudpaste-db --file=./schema.sql
Frontend setup
cd frontend
npm install
Configure environment variables
backend
directory, create a wrangler.toml
file to set development environment variablesfrontend
directory, configure the .env.development
file to set frontend environment variablesStart development servers
# Backend
cd backend
npm run dev
# Frontend (in another terminal)
cd frontend
npm run dev
CloudPaste/
├── frontend/ # Frontend Vue.js application
│ ├── src/ # Source code
│ │ ├── components/ # Vue components
│ │ ├── api/ # API clients and services
│ │ ├── i18n/ # Internationalization resource files
│ │ ├── utils/ # Utility functions
│ │ └── assets/ # Static assets
│ └── ...
└── backend/ # Cloudflare Workers backend
├── worker.js # Main Worker file
├── schema.sql # D1 database schema
└── ...
If you want to customize Docker images or debug during development, you can follow these steps to build manually:
Build backend image
# Execute in the project root directory
docker build -t cloudpaste-backend:custom -f docker/backend/Dockerfile .
# Run the custom built image
docker run -d --name cloudpaste-backend \
-p 8787:8787 \
-v $(pwd)/sql_data:/data \
-e ENCRYPTION_SECRET=development-test-key \
cloudpaste-backend:custom
Build frontend image
# Execute in the project root directory
docker build -t cloudpaste-frontend:custom -f docker/frontend/Dockerfile .
# Run the custom built image
docker run -d --name cloudpaste-frontend \
-p 80:80 \
-e BACKEND_URL=http://localhost:8787 \
cloudpaste-frontend:custom
Development environment Docker Compose
Create a docker-compose.dev.yml
file:
version: "3.8"
services:
frontend:
build:
context: .
dockerfile: docker/frontend/Dockerfile
environment:
- BACKEND_URL=http://backend:8787
ports:
- "80:80"
depends_on:
- backend
backend:
build:
context: .
dockerfile: docker/backend/Dockerfile
environment:
- NODE_ENV=development
- RUNTIME_ENV=docker
- PORT=8787
- ENCRYPTION_SECRET=dev_secret_key
volumes:
- ./sql_data:/data
ports:
- "8787:8787"
Start the development environment:
docker-compose -f docker-compose.yml up --build
Apache License 2.0
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
If you think the project is good I hope you can give a free star✨✨, Thank you very much!