Why Use a Custom Domain?
Without a custom domain, your files will have URLs like:- Professional branding - Use your own domain name
- Shorter URLs - Easier to share and remember
- Custom SSL - Cloudflare provides free SSL certificates
- Better control - Set custom headers, caching rules, etc.
Prerequisites
- A domain managed by Cloudflare (or transferable to Cloudflare)
- An R2 bucket already created (see R2 Setup)
- Access to your domain’s DNS settings
Step 1: Connect a Domain to Your R2 Bucket
Navigate to your R2 bucket
- Log in to the Cloudflare Dashboard
- Click R2 in the sidebar
- Select your bucket (e.g.,
zipdrop-uploads) - Go to the Settings tab
Add a custom domain
- Scroll to the Public access section
- Click Connect domain
- Enter your desired subdomain (e.g.,
files.yourdomain.com) - Click Continue
You can use any subdomain. Common choices:
files, cdn, uploads, static, mediaCloudflare configures DNS automatically
Cloudflare will:
- Create a CNAME record pointing to your R2 bucket
- Issue an SSL certificate for the subdomain
- Configure caching and delivery rules
Step 2: Configure ZipDrop to Use Your Custom Domain
Once your custom domain is active, update ZipDrop’s configuration:How ZipDrop Generates URLs
When you upload a file, ZipDrop constructs the public URL by combining:- Public URL Base (from your configuration)
- Object Key (generated automatically)
uploader.rs:215-217:
Object Key Format
ZipDrop generates unique, SEO-friendly keys for uploaded files (uploader.rs:141-164):
My Vacation Photo.jpg generates:
Configuration Examples
Example 1: Simple Subdomain
Custom Domain:files.example.com
ZipDrop Config:
Example 2: Subdomain with Path Prefix
Custom Domain:cdn.example.com
ZipDrop Config:
Path prefixes are optional. They’re useful if you’re sharing an R2 bucket with multiple applications.
Example 3: Using R2.dev Public URL
If you don’t have a custom domain, you can use Cloudflare’s built-in R2 public URL: ZipDrop Config:Advanced: Custom Headers and Caching
With a custom domain, you can configure advanced delivery settings:Cache Rules
- In the Cloudflare Dashboard, go to Caching → Cache Rules
- Create a rule for your subdomain:
- If: Hostname equals
files.yourdomain.com - Then: Cache everything with TTL of 1 month
- If: Hostname equals
Transform Rules
Add custom headers to all uploaded files:- Go to Rules → Transform Rules
- Create a rule:
- If: Hostname equals
files.yourdomain.com - Then: Set headers:
Access-Control-Allow-Origin: *(for CORS)Cache-Control: public, max-age=31536000(for long-term caching)
- If: Hostname equals
Hotlink Protection
Prevent other sites from embedding your files:- Go to Scrape Shield → Hotlink Protection
- Enable for your domain
- Add allowed domains to the allowlist
Troubleshooting
”Domain not active” after setup
- Wait 5-10 minutes for DNS propagation
- Check that your domain is on Cloudflare (orange cloud enabled)
- Verify the CNAME record was created correctly in DNS → Records
Files return 404 errors
- Verify the Public URL Base in ZipDrop matches your custom domain exactly
- Ensure there’s no trailing slash in the Public URL Base
- Check that the bucket is connected to the domain in R2 settings
SSL certificate errors
- Wait for Cloudflare to issue the SSL certificate (can take up to 24 hours)
- Ensure SSL/TLS encryption mode is set to Full or Full (strict) in Cloudflare
- Check that the domain is proxied through Cloudflare (orange cloud, not gray)
Mixed content warnings
- Always use
https://in your Public URL Base - Ensure Cloudflare’s SSL/TLS mode is Full or higher
- Check that your website is also served over HTTPS
Storage Location in Config
The Public URL Base is stored in the config file at~/Library/Application Support/zipdrop/config.json:
Next Steps
Best Practices
- Use a dedicated subdomain (e.g.,
files,cdn) instead of your root domain - Enable HTTPS - Cloudflare provides free SSL certificates
- Set up cache rules to improve delivery speed and reduce costs
- Monitor usage in the R2 analytics dashboard to track bandwidth and storage
- Consider CDN regions - Cloudflare’s global network ensures fast delivery worldwide