A Comprehensive Guide: How to Set Up Private Storage with Cloudflare R2 Buckets and S3 API Compatibility
Craft your personalized storage buckets, forging a realm of effortless file management and securely by Cloudflare R2
Project knowledgment. This project a powerful and user-friendly private file storage management, was born from a its self flexibility vision. The core concept, direction, and design were by © Greyscope&Co | 0xgrey resulting in a compactibility and intuitive storage clouding but securing. The project not only meets current needs but also anticipates personal requirements, ensuring a seamless and secure user experience.
- ❇️ Support Continuous: Full-stack deployment (backend and frontend), with UI/UX compatibility on both mobile and desktop
- 📊 Bucket Status: Realtime api data tracking, progress bar, bucket file stored, bucket size stored, unBucket size stored and bucket time reset (manage 10GB monthly)
- 📁 Bucket Files: Fast file uploads up to 1GB-more (configurable), search by filename, download count tracking, copy/share link functionality, and RAW file mode
- 🎨 UI Multiple Icons: Supports all icon media files and effects, with up to 6 files per slide in windows
- 🧩 Flexible Deploy: Compatible with Amazon S3 API (boto3) for flexible storage deployment
- 🗑️ Trash & Burn: Comprehensive storage file management with total cleanup functionality to prevent global S3/R2 issues
- 🐳 Docker: Ready for production and development, fully container-optimized with double/redirect host proxy, fastest no-caching built-in Nginx configuration, and resource usage monitoring
- ☁️ Cloudflare: Utilizes R2 private storage infrastructure for secure data management
cloudflare-storage/
├── .gitignore
├── .dockerignore
├── .env.example
├── docker-compose.yml
├── backend/
+ ├── README.md # Guides delete buckets R2/AWS-S3
│ ├── Dockerfile
│ ├── requirements.txt
│ ├── app.py
│ ├── delete_buckets.py
│ └── data/
│ └── .gitkeep
├── frontend/
│ ├── Dockerfile
│ ├── nginx.conf.template
│ ├── index.html
│ ├── style.css
│ ├── script.js
│ └── src/
│ └── favicon.ico
├── docs/
+ ├── README.md # Guides main host nginx + template
│ └── /etc/nginx/sites-available/your-domain
│
├── LICENSE
└── README.mdSignup & Securely Cloudflare Access
- Dashboard R2 settings → https://dash.cloudflare.com/?to=/:account/r2/overview
- Buy domain up to you (Recommended for use an infra cloudflare)
- Free tier is limit Per/month 10GB (resetting)
Install Docker & Compose if not already installed
Instal docker is optional, if you don't have.. try securely
curl -sSL https://raw.githubusercontent.com/arcxteam/succinct-prover/refs/heads/main/docker.sh | sudo bash
git clone https://github.com/arcxteam/cloudflare-storage.git
cd cloudflare-storage
Create edit & save configuration file
cp .env.example .env
nano .envExample config environment variable
R2_ACCOUNT_ID=YOUR_ACCOUNT_ID
R2_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID
R2_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
R2_BUCKET_NAME=YOUR_NAME_CREATE_BUCKETS
+ Enabled (Public Development URL or Custom Domains, Create Record A sub-sub-domain)
R2_PUBLIC_URL=https://pub-xxxxx.r2.dev or https://sub-sub-your-domain.com
# NOTE: Choose one, personal access web-ui dashboard (upload/download)
+ Option A: IP Public server
PUBLIC_BASE_URL=http://your-ip-address
+ Option B: Localnetwork (VSCode/Codespaces/etc)
PUBLIC_BASE_URL=http://localhost
+ Option C: Custom domains
PUBLIC_BASE_URL=https://your-domain.com or sub-domain- Access Dashboard Cloudflare
- Chosee Storage & database → R2 Object Storage → Overview
- Create bucket
- Add Detail Bucket:
- Bucket name: Create unique
- Location: Automatic
- Save → Create bucket
- Return to R2, then select Manage R2 API tokens.
- Select Create Account API Tokens.
- In Permissions, select Object Read & Write.
- In Specify bucket(s), choose Apply to specific buckets only. Select the bucket you created.
- For TTL default is forever or Define how long this token will stay active:
- For Client IP Address Filtering no have action default is blank/null
- Select Create API Token.
- Copy the Access Key ID, Secret Access Key, and endpoint URL values. You will not be able to access these values again.
- Select Finish.
- Use mode Custom Domain (Production)
- Policy name:
web-app-cors - Allowed origins:
https://your-domain - Allowed methods: Pilih
GET,POST,PUT,DELETE,HEAD - Allowed headers:
* - Max age seconds:
86400 - Click "Add policy or save"`
- Use mode Localhost/Development
- Policy name:
dev-cors-policy - Allowed origins:
http://localhost:5000, http://127.0.0.1:5000 - Other are same & TLS 1.3 optional
Choose one CORS above, a format JSON
[
{
"AllowedOrigins": ["https://your-domain", "http://localhost:5000", "http://127.0.0.1:5000"],
"AllowedMethods": ["GET", "POST", "PUT", "DELETE", "HEAD"],
"AllowedHeaders": ["*"],
"MaxAgeSeconds": 86400
}
]Starting running
docker compose up --build -d
Monitor logs & stop
docker compose logs -f
# docker compose down
This project is licensed under the MIT License - see the LICENSE file for details.