【白嫖】使用 CloudFlare R2 搭建个人图床

Last updated on February 26, 2024 pm

优点介绍

  1. 免费额度足够个人使用
  2. 无需额外配置 CDN
  3. 自定义域名比较优雅
Free Paid - Rates
存储 10 GB / month $0.015 / GB-month
A 类操作 1 million requests / month $4.50 / million requests
B 类操作 10 million requests / month $0.36 / million requests

第一步 创建 R2 存储桶

第二步 绑定域名

第三步 创建 S3 令牌


第四步 安装 lsky 图床

1
2
mkdir -p ~/app/Lsky && cd ~/app/Lsky && nano docker-compose.yml
docker-compose up -d
1
2
3
4
5
6
7
8
9
10
11
12
version: '3.3'
services:
lsky-pro:
restart: always
volumes:
- './lsky-pro-data:/var/www/html'
image: 'dko0/lsky-pro'

networks:
default:
external: true
name: ngpm

第五步 图床添加 R2 储存桶

附加 图床备份

1
2
sudo -v ; curl https://rclone.org/install.sh | sudo bash -s beta
nano ~/.config/rclone/rclone.conf
1
2
3
4
5
6
7
[img]
type = s3
provider = Cloudflare
access_key_id = xxx
secret_access_key = xxxxxx
endpoint = https://<accountid>.r2.cloudflarestorage.com
acl = private
1
2
3
4
5
rclone lsd img:limour-img
git clone https://oauth2:ghp_xxx@github.com/limour-blog/img-bed.git
rclone copy --ignore-existing --progress --ignore-errors img:limour-img ~/img-bed
cd ~/img-bed
git add . && git commit -m 'backup' && git push -u origin main

附加 图片预处理

1
2
3
4
5
6
D:\ImageMagick-7.1.1-Q16\magick.exe convert -resize 512x512^ -gravity North -extent 512x512 -quality 50 -define WebP:lossless=false F:\temp\randImg\*.jpg 26.wenbp
# 顶部 -gravity North
# 底部 -gravity South
# 中间 -gravity center
# 右侧 -gravity East
# 左侧 -gravity West

【白嫖】使用 CloudFlare R2 搭建个人图床
https://hexo.limour.top/-bai-piao--shi-yong-CloudFlare-R2-da-jian-ge-ren-tu-chuang
Author
Limour
Posted on
August 27, 2023
Updated on
February 26, 2024
Licensed under