posts: 添加warden-worker项目的博文,实现BitWarden在Cloudflare Worker上的部署指南

This commit is contained in:
二叉树树
2025-11-21 18:37:23 +08:00
parent 24ca6c12c3
commit c79452da96
26 changed files with 91 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

View File

@@ -0,0 +1,91 @@
---
title: 你可曾想过直接将BitWarden部署到Cloudflare Worker
published: 2025-11-21T17:07:52
description: warden-worker就是这样一个项目它将Rust编译为WASM然后部署到Cloudflare Worker无需VPS无需家里云只需点点鼠标就可免费用上自己的密码托管
image: ../assets/images/warden-worker.png
tags:
- Cloudflare
- Bitwarden
draft: false
lang: ""
---
# 原理
项目参考开源的 [dani-garcia/vaultwarden: Unofficial Bitwarden compatible server written in Rust, formerly known as bitwarden_rs](https://github.com/dani-garcia/vaultwarden) 将Rust源码编译为WASM以支持在Cloudflare Worker上运行。其中Worker负责REST APID1负责存储加密后的数据
# 实战
打开Cloudflare https://dash.cloudflare.com/
登录后复制这里的 **账户ID** CLOUDFLARE_ACCOUNT_ID
![](../assets/images/warden-worker-2.png)
右上角进入配置文件
![](../assets/images/warden-worker-1.png)
左上角选择API令牌
![](../assets/images/warden-worker-3.png)
点击创建令牌
![](../assets/images/warden-worker-4.png)
选择 编辑Cloudflare Workers
![](../assets/images/warden-worker-5.png)
创建后 **复制API 令牌** 只会展示一次CLOUDFLARE_API_TOKEN
![](../assets/images/warden-worker-6.png)
回到主页进入D1数据库
![](../assets/images/warden-worker-7.png)
选择 创建数据库
![](../assets/images/warden-worker-8.png)
创建完成后,进入,复制 **D1 数据库 ID**D1_DATABASE_ID
> 由于原项目坑点太多依赖不固定版本导致编译报错必须设置的环境变量不写白SQL初始化遇到问题直接跳过
这里我Fork并二改了一个我的版本跟着我的步骤走包你成功
Fork我的仓库别忘了点个 **Star** [afoim/warden-worker: A Bitwarden-compatible server for Cloudflare Workers](https://github.com/afoim/warden-worker/)
在仓库设置中添加上述三个机密环境变量
- `CLOUDFLARE_ACCOUNT_ID`
- `CLOUDFLARE_API_TOKEN`
- `D1_DATABASE_ID`
![](../assets/images/warden-worker-9.png)
点击 Action运行Build工作流
![](../assets/images/warden-worker-10.png)
Build结束全绿
![](../assets/images/warden-worker-11.png)
打开Cloudflare D1查看数据库表
![](../assets/images/warden-worker-12.png)
如果这里是空的,我们就手动建表
![](../assets/images/warden-worker-13.png)
查看这个文件 [warden-worker/sql/schema.sql at main · afoim/warden-worker](https://github.com/afoim/warden-worker/blob/main/sql/schema.sql)
依次将这3个SQL块进行执行一定要依次不能一把梭。每执行一次你应该都能看到新表的出现
![](../assets/images/warden-worker-14.png)
![](../assets/images/warden-worker-15.png)![](../assets/images/warden-worker-16.png)
进入Workers
![](../assets/images/warden-worker-17.png)
进入 warden-worker
![](../assets/images/warden-worker-18.png)
先添加 **自定义域** ,填你的域名,因为 Worker 默认给的域名国内无法访问
![](../assets/images/warden-worker-19.png)
再添加**变量与机密** (注意不要有空格)
- `ALLOWED_EMAILS` your-email@example.com
- `JWT_SECRET` 随机的长字符串
- `JWT_REFRESH_SECRET` 随机的长字符串
![](../assets/images/warden-worker-20.png)
此时打开手机上的 **BitWarden** 软件,在你的自托管上创建账号即可(注意:密码一经设置将无法更改)
![](../assets/images/Screenshot_2025-11-21-17-53-07-65_edf9c6c5202cf0a.jpg)![](../assets/images/Screenshot_2025-11-21-17-53-04-92_edf9c6c5202cf0a.jpg)![](../assets/images/Screenshot_2025-11-21-17-53-34-66_edf9c6c5202cf0a.jpg)![](../assets/images/Screenshot_2025-11-21-18-32-58-31_edf9c6c5202cf0a.jpg)