图床
目标
搭建一个部署在树莓派上的自用图床,满足下面几个需求:
- 图片上传后保存到树莓派本地
- 生成可外部访问的 HTTPS 链接
- 使用固定域名
https://img.lxxsfile.org - 提供一个网页拖拽上传页面:
https://img.lxxsfile.org/uploader/
最终架构
浏览器 / 本地电脑
-> 上传图片
-> EasyTypora
-> 图片保存到树莓派本地目录 /opt/EasyTypora/server/assets/
-> Nginx 提供访问
-> Cloudflare Tunnel 暴露为 HTTPS
-> https://img.lxxsfile.org/assets/xxx.png
当前环境
- 树莓派系统:Debian 13 (trixie)
- 架构:aarch64 / arm64
- Node.js:v20.19.2
- npm:9.2.0
- nginx:1.26.3
- 固定图床域名:
https://img.lxxsfile.org - 网页上传入口:
https://img.lxxsfile.org/uploader/
一、安装基础环境
在树莓派上安装 Node.js、npm、nginx:
sudo apt update
sudo apt install -y nodejs npm nginx
检查版本:
node -v
npm -v
nginx -v
systemctl status nginx --no-pager
二、部署 EasyTypora
拉取代码并安装依赖:
cd /opt
sudo git clone --depth 1 https://github.com/zhaoolee/EasyTypora.git
sudo chown -R $USER:$USER /opt/EasyTypora
cd /opt/EasyTypora
npm i
三、配置 EasyTypora
编辑配置文件:
cd /opt/EasyTypora
nano conf.js
最终配置为:
module.exports = {
host: "https://img.lxxsfile.org",
server_port: "12800",
client_port: "443",
secret_token: "<your_secret_token>"
}
说明:
host:最终对外访问域名server_port:EasyTypora 实际监听端口client_port:对外是 HTTPS,所以填443secret_token:上传鉴权口令
启动服务:
cd /opt/EasyTypora
npm start
之后重启服务使用:
cd /opt/EasyTypora
npx pm2 restart index
检查本地服务:
curl http://127.0.0.1:12800/info
四、配置 Nginx 反向代理
编辑 Nginx 默认站点:
sudo nano /etc/nginx/sites-available/default
最终配置核心内容如下:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
client_max_body_size 50M;
location = /uploader {
return 301 /uploader/;
}
location /uploader/ {
alias /var/www/img-uploader/;
index index.html;
autoindex off;
}
location /assets/ {
alias /opt/EasyTypora/server/assets/;
autoindex off;
}
location / {
proxy_pass http://127.0.0.1:12800;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
检查并重载:
sudo nginx -t
sudo systemctl reload nginx
五、Cloudflare Tunnel 固定域名
没有继续使用临时 trycloudflare.com,而是使用已有正式 tunnel,为图床新增一条发布应用路由:
- 子域名:
img - 域名:
lxxsfile.org - 类型:
HTTP - URL:
localhost:80 - Path:留空
最终得到固定地址:
https://img.lxxsfile.org
这条路由把公网 HTTPS 请求转发到树莓派本机 Nginx 的 80 端口。
六、验证上传是否成功
测试上传命令:
curl -F 'file=@/opt/EasyTypora/test.txt' \
-F 'secret_token=<your_secret_token>' \
https://img.lxxsfile.org/upload_file
成功后会返回类似:
https://img.lxxsfile.org/assets/xxxxxxxxxxxxxxxx.png
说明图床已经打通。
七、图片实际保存位置
上传的图片保存在树莓派本地:
/opt/EasyTypora/server/assets/
查看文件:
ls -lh /opt/EasyTypora/server/assets/
ls -lht /opt/EasyTypora/server/assets/ | head
这说明:
- 图片本体在树莓派本地磁盘
- Cloudflare 只负责转发 HTTPS 访问
- 图片不是存放在 Cloudflare 上
八、实现网页拖拽上传器
为了避免 PicGo 插件兼容性问题,最后采用了更稳的方案:
直接在树莓派上部署一个网页上传器。
页面路径:
https://img.lxxsfile.org/uploader/
1. 创建网页目录
sudo mkdir -p /var/www/img-uploader
sudo nano /var/www/img-uploader/index.html
2. 页面功能
上传页面实现了:
- 输入并保存
secret_token - 支持拖拽图片上传
- 支持点击选择图片上传
- 支持多图上传
- 上传成功后显示 HTTPS 链接
- 自动复制链接到剪贴板
九、现在的实际使用方式
现在使用图床非常简单:
- 打开网页:
https://img.lxxsfile.org/uploader/
- 输入当前
secret_token - 点“保存 token”
- 把图片直接拖进去
- 复制返回的 HTTPS 链接
最终链接格式:
https://img.lxxsfile.org/assets/xxxxx.png
十、曾经踩过的坑
1. Quick Tunnel 只适合测试
使用 cloudflared tunnel --url http://localhost:80 可以快速拿到 trycloudflare.com 地址,但:
- 地址是临时的
- 关掉终端就失效
- 不适合长期使用
所以后来改成了正式 tunnel + 固定域名。
2. PicGo 插件兼容性差
pi-picgo 插件在编译后虽然生成了 dist/index.js,但在 PicGo 2.5.2 里没有被稳定识别出来。
所以最终没有继续强行依赖 PicGo,而是改成了网页拖拽上传页。
3. 本地终端和 SSH 终端不要混
- 树莓派上的服务配置、Nginx、EasyTypora 在 SSH 里操作
- 本地图形软件(PicGo)应该在自己电脑本地打开,不应在 SSH 里尝试运行 GUI
十一、保留的关键路径
EasyTypora 项目目录
/opt/EasyTypora
图片保存目录
/opt/EasyTypora/server/assets/
网页上传器目录
/var/www/img-uploader/
Nginx 配置文件
/etc/nginx/sites-available/default
十二、常用维护命令
重启 EasyTypora
cd /opt/EasyTypora
npx pm2 restart index
检查 EasyTypora 信息
curl http://127.0.0.1:12800/info
检查 Nginx 配置
sudo nginx -t
重载 Nginx
sudo systemctl reload nginx
查看 Nginx 错误日志
sudo tail -n 30 /var/log/nginx/error.log
测试上传页
curl https://img.lxxsfile.org/uploader/
十三、当前结论
这套图床已经完成,并且能正常使用。
当前具备:
- 固定 HTTPS 域名图床
- 图片保存到树莓派本地
- 浏览器拖拽上传
- 自动返回可用外链
当前最终入口:
- 图床主页:
https://img.lxxsfile.org - 上传页:
https://img.lxxsfile.org/uploader/
这个时刻的记录
记录时间:2026-04-04
今天完成了从零开始把树莓派做成 HTTPS 图床,并且最终采用网页拖拽上传方式,绕过了老旧 PicGo 插件兼容性问题,得到了一个稳定、可长期使用的自用图床方案。

这是啥啊
图片存为https的工具