posts: 更新warden-worker部署指南,提供了详细的部署步骤以及迁移步骤

This commit is contained in:
二叉树树
2026-01-26 22:26:13 +08:00
parent 376f19cb5d
commit 771eb3a16c
42 changed files with 80 additions and 80 deletions

View File

@@ -16,7 +16,7 @@ const __dirname = path.dirname(__filename);
const CONTENT_DIR = path.join(process.cwd(), "src/content"); const CONTENT_DIR = path.join(process.cwd(), "src/content");
const POSTS_DIR = path.join(CONTENT_DIR, "posts"); const POSTS_DIR = path.join(CONTENT_DIR, "posts");
const ASSETS_DIR = path.join(CONTENT_DIR, "img"); const ASSETS_DIR = path.join(CONTENT_DIR, "assets/images");
// 支持的图片格式 // 支持的图片格式
const IMAGE_EXTENSIONS = [ const IMAGE_EXTENSIONS = [

View File

@@ -13,12 +13,12 @@
"state": { "state": {
"type": "markdown", "type": "markdown",
"state": { "state": {
"file": "posts/del-git-commit.md", "file": "posts/warden-worker.md",
"mode": "source", "mode": "source",
"source": false "source": false
}, },
"icon": "lucide-file", "icon": "lucide-file",
"title": "del-git-commit" "title": "warden-worker"
} }
} }
] ]
@@ -94,7 +94,7 @@
"state": { "state": {
"type": "backlink", "type": "backlink",
"state": { "state": {
"file": "posts/del-git-commit.md", "file": "posts/warden-worker.md",
"collapseAll": false, "collapseAll": false,
"extraContext": false, "extraContext": false,
"sortOrder": "alphabetical", "sortOrder": "alphabetical",
@@ -104,7 +104,7 @@
"unlinkedCollapsed": true "unlinkedCollapsed": true
}, },
"icon": "links-coming-in", "icon": "links-coming-in",
"title": "del-git-commit 的反向链接列表" "title": "warden-worker 的反向链接列表"
} }
}, },
{ {
@@ -113,12 +113,12 @@
"state": { "state": {
"type": "outgoing-link", "type": "outgoing-link",
"state": { "state": {
"file": "posts/del-git-commit.md", "file": "posts/warden-worker.md",
"linksCollapsed": false, "linksCollapsed": false,
"unlinkedCollapsed": true "unlinkedCollapsed": true
}, },
"icon": "links-going-out", "icon": "links-going-out",
"title": "del-git-commit 的出链列表" "title": "warden-worker 的出链列表"
} }
}, },
{ {
@@ -142,13 +142,13 @@
"state": { "state": {
"type": "outline", "type": "outline",
"state": { "state": {
"file": "posts/del-git-commit.md", "file": "posts/warden-worker.md",
"followCursor": false, "followCursor": false,
"showSearch": false, "showSearch": false,
"searchQuery": "" "searchQuery": ""
}, },
"icon": "lucide-list", "icon": "lucide-list",
"title": "del-git-commit 的大纲" "title": "warden-worker 的大纲"
} }
} }
] ]
@@ -171,6 +171,17 @@
}, },
"active": "ea8fe4fe54e0109e", "active": "ea8fe4fe54e0109e",
"lastOpenFiles": [ "lastOpenFiles": [
"assets/images/warden-worker-33.png",
"assets/images/warden-worker-32.png",
"assets/images/warden-worker-31.png",
"assets/images/warden-worker-30.png",
"assets/images/warden-worker-29.png",
"assets/images/warden-worker-28.png",
"assets/images/warden-worker-27.png",
"assets/images/warden-worker-26.png",
"assets/images/warden-worker-25.png",
"assets/images/warden-worker-24.png",
"posts/del-git-commit.md",
"posts/vercel-github.md", "posts/vercel-github.md",
"posts/go-proxy-gh.md", "posts/go-proxy-gh.md",
"posts/giscus-akismet.md", "posts/giscus-akismet.md",
@@ -179,19 +190,9 @@
"posts/ghedu-free-me.md", "posts/ghedu-free-me.md",
"posts/eopf-github-proxy.md", "posts/eopf-github-proxy.md",
"assets/images/del-git-commit-16.png", "assets/images/del-git-commit-16.png",
"assets/images/del-git-commit-15.png",
"assets/images/del-git-commit-14.png",
"assets/images/del-git-commit-13.png",
"assets/images/del-git-commit-12.png",
"assets/images/del-git-commit-11.png",
"assets/images/del-git-commit-10.png",
"posts/mac-gal.md", "posts/mac-gal.md",
"posts/self-host-matrix.md", "posts/self-host-matrix.md",
"posts/gal.md", "posts/gal.md",
"posts/del-git-commit.md",
"assets/images/del-git-commit-9.png",
"assets/images/del-git-commit-8.png",
"assets/images/del-git-commit-7.png",
"2024-11-20.md", "2024-11-20.md",
"posts/fuwari.md" "posts/fuwari.md"
] ]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 91 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 202 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

View File

@@ -12,92 +12,91 @@ 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负责存储加密后的数据 项目参考开源的 [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/ 首先确保你安装了Rust若无可前往 [安装 Rust - Rust 程序设计语言](https://rust-lang.org/zh-CN/tools/install/)
登录后复制这里的 **账户ID** CLOUDFLARE_ACCOUNT_ID 克隆仓库: [afoim/warden-worker: A Bitwarden-compatible server for Cloudflare Workers](https://github.com/afoim/warden-worker)
![](../assets/images/warden-worker-2.png)
右上角进入配置文件 创建D1数据库
![](../assets/images/warden-worker-1.png) ```sql
wrangler d1 create vault1
```
左上角选择API令牌 ![](../assets/images/warden-worker-25.png)
![](../assets/images/warden-worker-3.png)
点击创建令牌 替换 **wrangler.jsonc** 的数据库ID
![](../assets/images/warden-worker-4.png)
选择 编辑Cloudflare Workers ![](../assets/images/warden-worker-26.png)
![](../assets/images/warden-worker-5.png)
创建后 **复制API 令牌** 只会展示一次CLOUDFLARE_API_TOKEN 初始化数据库
![](../assets/images/warden-worker-6.png)
回到主页进入D1数据库 ```sql
![](../assets/images/warden-worker-7.png) wrangler d1 execute warden-sql --remote --file=sql/schema_full.sql
```
选择 创建数据库 ![](../assets/images/warden-worker-27.png)
![](../assets/images/warden-worker-8.png)
创建完成后,进入,复制 **D1 数据库 ID**D1_DATABASE_ID 编译Rust WASM
> 由于原项目坑点太多依赖不固定版本导致编译报错必须设置的环境变量不写白SQL初始化遇到问题直接跳过 ```bash
cargo build --release
```
部署 Worker
这里我Fork并二改了一个我的版本跟着我的步骤走包你成功 ```bash
wrangler deploy
```
Fork我的仓库别忘了点个 **Star** [afoim/warden-worker: A Bitwarden-compatible server for Cloudflare Workers](https://github.com/afoim/warden-worker/) 设置白名单邮箱
在仓库设置中添加上述三个机密环境变量 ```bash
- `CLOUDFLARE_ACCOUNT_ID` wrangler secret put ALLOWED_EMAILS
- `CLOUDFLARE_API_TOKEN` ```
- `D1_DATABASE_ID`
![](../assets/images/warden-worker-9.png)
点击 Action运行Build工作流 ![](../assets/images/warden-worker-29.png)
![](../assets/images/warden-worker-10.png)
Build结束全绿 设置JWT脸滚键盘即可
![](../assets/images/warden-worker-11.png)
打开Cloudflare D1查看数据库表 ```bash
![](../assets/images/warden-worker-12.png) wrangler secret put JWT_SECRET
wrangler secret put JWT_REFRESH_SECRET
```
如果这里是空的,我们就手动建表 ![](../assets/images/warden-worker-30.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) 设置2FA加密密钥32字节Base64编码文本
依次将这3个SQL块进行执行一定要依次不能一把梭。每执行一次你应该都能看到新表的出现 ```bash
![](../assets/images/warden-worker-14.png) wrangler secret put TWO_FACTOR_ENC_KEY
![](../assets/images/warden-worker-15.png)![](../assets/images/warden-worker-16.png) ```
进入Workers Poweshell可以这样生成
![](../assets/images/warden-worker-17.png)
进入 warden-worker ```powershell
![](../assets/images/warden-worker-18.png) [Convert]::ToBase64String((1..32 | ForEach-Object {Get-Random -Minimum 0 -Maximum 256}))
```
先添加 **自定义域** ,填你的域名,因为 Worker 默认给的域名国内无法访问 ![](../assets/images/warden-worker-31.png)
![](../assets/images/warden-worker-19.png)
再添加**机密环境变量** (注意不要有空格 前往控制台绑定域名若路由需要手动写一条解析到Cloudflare
- `ALLOWED_EMAILS` your-email@example.com
- `JWT_SECRET` 随机的长字符串
- `JWT_REFRESH_SECRET` 随机的长字符串
> [!CAUTION]
> 必须使用Wrangler CLI命令添加机密环境变量 `wrangler secret put JWT_SECRET` 这样添加的环境变量不会在新的部署中被覆盖
![](../assets/images/warden-worker-22.png) ![](../assets/images/warden-worker-28.png)
![](../assets/images/warden-worker-23.png) 使用移动端Bitwarden创建账号使用白名单邮箱
此时打开手机上的 **BitWarden** 软件,在你的自托管上创建账号即可(注意:密码一经设置将无法更改 接下来前往网页端启用2FA https://cfbw.2x.nz 用另一个TOTP验证器存储
![](../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)
> [!CAUTION] *顺便一提,想要修改邮箱或主密码也可以在网页端进行了*
> ~~值得注意的是该项目似乎仅实现了手机端的大部分API而针对于电脑浏览器插件使用的API暂未支持我们目前正在尝试用AI补全... Just a moment...~~
> ![](../assets/images/warden-worker-32.png)
> 更多注意事项请参阅仓库README
> 将所有已登录的设备登出后再登入则会被要求TOTP
> 已支持电脑端浏览器插件
# 导入密码库
如果您有旧的密码库,请先前往 **设置 - 密码库选项 - 导出 - .json**
再登录当前密码库,前往 **设置 - 密码库选项 - 导入 - .json**
![](../assets/images/warden-worker-33.png)