使用子域名部署bitwarden
之前把bitwarden成功部署在主域名上文章,但占用了主页 。改为使用subpath不是太舒服又会遇到插件无法打开网页版的小问题(可能是我的Caddy配置不对。。。)。所以就把bitwarden部署在子域名下,顺带学习一下网络知识
步骤
域名添加一条A记录
我的vps、域名都是阿里云的,在域名解析上添加一个w子域名的A记录
DNS资源记录,这几个一定要记住:
A: 域名指向ipv4地址
AAAA:域名指向ipv6地址
CNAME:域名指向另外一个域名
MX:域名指向邮件服务器
NS:指向另外的DNS解析
ping一下,确认域名已经解析成功。由于是阿里云的vps,一定要用备案的域名哟。。。。
修改Caddy配置
添加一个w.domain.xyz
的配置,具体可以看GitHub的示例https://github.com/dani-garcia/vaultwarden/wiki/Proxy-examples
[root@deng caddy]# cat Caddyfile
(common) {
header /* {
-Server
}
encode gzip
route /otp* {
uri strip_prefix /otp
reverse_proxy 0.0.0.0:8090
}
log {
output file /var/log/caddy/d.com-access.log {
roll_size 10mb
roll_keep 20
roll_keep_for 720h
}
}
}
domain.xyz {
root * /usr/share/caddy
file_server
import common
}
# subdomian
w.domain.xyz {
# Notifications redirected to the websockets server
reverse_proxy /notifications/hub 0.0.0.0:3012
reverse_proxy 0.0.0.0:8080 {
# Send the true remote IP to Rocket, so that vaultwarden can put this in the
# log, so that fail2ban can ban the correct IP.
header_up X-Real-IP {remote_host}
}
import common
}
重启caddy
docker restart caddy
验证
访问子域名一切正常,收工