简介
Bitwarden 客户端 API 的替代服务器实现,用 Rust 编写,与官方 Bitwarden 客户端兼容,非常适合自托管部署,其中运行官方资源密集型服务可能不理想。
源码:https://github.com/dani-garcia/vaultwarden
部署
docker compose
1
2
3
4
5
6
7
8
9
10
11
12
13
|
version: '3.9'
services:
vaultwarden:
container_name: vaultwarden
image: vaultwarden/server:latest
environment:
- SIGNUPS_ALLOWED=false # 禁用新用户注册
- SIGNUPS_ALLOWED=false # 禁用组织邀请
volumes:
- ./vaultwarden_data/:/data/
ports:
- 3035:80
restart: unless-stopped
|
启用管理界面
环境变量
1
|
ADMIN_TOKEN=some_random_token_as_per_above_explanation # 启用管理页面
|
使用如下命令生成 argon2 加密后的 token
1
|
docker exec -it <container_id> /vaultwarden hash
|
将 $
替换成 $$
添加到 ADMIN_TOKEN 后面,注意,不要加''
smtp 邮件发送
配置
环境变量
1
2
3
4
5
6
|
SMTP_HOST= # smtp host
SMTP_FROM= # smtp 发件人
SMTP_PORT= # smtp 端口
SMTP_SECURITY= # smtp tls加密方式,可选有force_tls,starttls,off
SMTP_USERNAME= # smtp 用户名
SMTP_PASSWORD= # smtp 用户密码
|
smtp 服务器
Resnd:每个月免费 3000 封,注册添加域名后可能被封,需要发邮件解封
端口对应的 TLS
1
2
|
SMTP_PORT=465
SMTP_SECURITY=force_tls
|
1
2
|
SMTP_PORT=587
SMTP_SECURITY=starttls
|
1
2
|
SMTP_PORT=25
SMTP_SECURITY=off
|
示例
resend
1
2
3
4
5
6
|
SMTP_HOST=smtp.resend.com
SMTP_FROM=no-reply@example.com
SMTP_PORT=465
SMTP_SECURITY=force_tls
SMTP_USERNAME=resend
SMTP_PASSWORD=re_Pxxxxxxxxxx
|
反向代理
Nginx
请将 yourdomain
替换为自己的域名
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
server {
if ($host = yourdomain.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name yourdomain.com;
return 301 https://yourdomain.com$request_uri;
}
server {
listen 443 ssl;
http2 on;
server_name yourdomain.com;
# SSL 证书配置
ssl_certificate /etc/nginx/ssl/yourdomain.com/cert.pem;
ssl_certificate_key /etc/nginx/ssl/yourdomain.com/key.pem;
# 安全设置
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# 反向代理
location / {
proxy_pass http://127.0.0.1:3035/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
}
# 日志配置
access_log /var/log/nginx/yourdomain.com.access.log;
error_log /var/log/nginx/yourdomain.com.error.log;
}
|