Actual软件搭建
搭建过的服务器配置:
Operating System: Ubuntu 24.04 LTSKernel: Linux 6.8.0-40-genericArchitecture: x86-64安装Docker
Section titled “安装Docker”https://cloud.tencent.com/document/product/1207/45596?from=console_document_search
安装Actual
Section titled “安装Actual”https://www.actualbudget.com/docs/install/docker
不配置证书会出现报错,也可以强制访问,但是可能会出现问题,详细信息:https://www.actualbudget.com/docs/troubleshooting/shared-array-buffer/
使用域名证书
Section titled “使用域名证书”根据域名提供商进行配置。 Actual 中的证书配置查看:https://www.actualbudget.com/docs/config/https/
使用反向代理
Section titled “使用反向代理”没有域名可以使用免费的反向代理。 配置参考:https://www.actualbudget.com/docs/config/reverse-proxies/
反向代理域名无法访问
Section titled “反向代理域名无法访问”可能会存在一些防火墙之类的不常见网络问题,造成反向代理提供的域名无法使用,所以可以通过本地自签名,然后使用SSH将服务器端口映射到本地进行访问。
服务器如果有公网IP,然后只开启了反向代理,是可以通过http+IP的方式进行访问的,但是Actual会报错。
https://github.com/FiloSottile/mkcert
然后直接使用 https://IP:5006 的方式访问。
安装mkcert
Section titled “安装mkcert”安装
apt install libnss3-toolsapt install mkcert创建文件
vim openssl.cnf[ req ]default_bits = 2048distinguished_name = req_distinguished_namereq_extensions = req_extx509_extensions = v3_ca
[ req_distinguished_name ]countryName = Country Name (2 letter code)countryName_default = AUstateOrProvinceName = State or Province Name (full name)localityName = Locality Name (eg, city)organizationName = Organization Name (eg, company)organizationalUnitName = Organizational Unit Name (eg, section)commonName = Common Name (e.g. server FQDN or YOUR name)commonName_default = localhost
[ req_ext ]subjectAltName = @alt_names
[ v3_ca ]subjectAltName = @alt_names
[ alt_names ]DNS.1 = localhost生成证书
mkcert localhost拆分出证书和key
awk '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/' localhost.pem > selfhost.crtawk '/-----BEGIN PRIVATE KEY-----/,/-----END PRIVATE KEY-----/' localhost-key.pem > selfhost.key使用 Let’s Encrypt 签发免费的 IP 地址证书
Section titled “使用 Let’s Encrypt 签发免费的 IP 地址证书”参考:https://www.appinn.com/letsencrypt-issue-ip-ssl-certificates/
这个是最终方案
安装 / 升级 acme.sh
Section titled “安装 / 升级 acme.sh”acme.sh 是著名的自动化证书签发程序,支持 Let’s Encrypt、ZeroSSL 等不同的证书提供商。
curl https://get.acme.sh | sh -s email=my@example.com如果安装过,那么升级方式:./acme.sh upgrade
使用独立方式,独立方式是服务器中本身没有 Web 服务,acme.sh 会自己运行一个 Web 服务来进行验证(myIP换成IP):
./.acme.sh/acme.sh --issue --server letsencrypt -d 64.23.194.105 --certificate-profile shortlived --days 3 --standalone命令具体解析如下:
./acme.sh:执行 acme.sh 脚本。--issue:申请一个新证书。--server letsencrypt:使用 Let’s Encrypt 服务器。-d 64.23.194.105:证书申请的目标是 IP 地址 64.23.194.105(该IP用于测试,已被删除)--certificate-profile shortlived:申请一个短期证书(最长90天?)。--days 3:证书的有效期是 3 天。--standalone:使用 standalone 模式验证,不依赖现有的 Web 服务器。(需要80/443端口)生成的证书默认保存在 /root/.acme.sh/64.23.194.105_ecc/ 路径下,你要使用的是:
/root/.acme.sh/64.23.194.105_ecc/64.23.194.105.key (私钥)/root/.acme.sh/64.23.194.105_ecc/fullchain.cer (完整证书链)修改config.json
Section titled “修改config.json”将密钥的文件名称修改,data目录是本地目录/root/actual挂载在docker中的目录,所以将证书文件放在/root/actual目录下,但是config.json中要写data目录。
root@VM-8-10-ubuntu:~# cat /root/actual/config.json{ "https": { "key": "/data/64.23.194.105.key", "cert": "/data/fullchain.cer" }}crontab -e
0 0 * * * /root/.acme.sh/acme.sh --cron --home /root/.acme.sh > /dev/null每 2 天上午 03:00 运行一次
0 3 */2 * * /root/.acme.sh/acme.sh --cron --home /root/.acme.sh; sleep 60; [ -s /root/.acme.sh/64.23.194.105_ecc/64.23.194.105.key ] && [ -s /root/.acme.sh/64.23.194.105_ecc/fullchain.cer ] && cp /root/.acme.sh/64.23.194.105_ecc/64.23.194.105.key /root/actual/64.23.194.105.key && cp /root/.acme.sh/64.23.194.105_ecc/fullchain.cer /root/actual/fullchain.cer && ( docker ps -a --format '{{.Names}}' | grep -qx my_actual_budget && docker stop my_actual_budget >/dev/null 2>&1 && docker rm my_actual_budget >/dev/null 2>&1 || true ) && docker run --pull=always --restart=unless-stopped -d -p 5006:5006 -v /root/actual:/data --name my_actual_budget actualbudget/actual-server:latest本地映射服务器端口访问
Section titled “本地映射服务器端口访问”创建用户并使用key登录
Section titled “创建用户并使用key登录”创建 SSH Key
ssh-keygen -t rsa设置 Kye 公钥
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keyschmod 600 ~/.ssh/authorized_keys示例:将本地端口 8080 映射到远程服务器的端口 80,并在后台运行
Section titled “示例:将本地端口 8080 映射到远程服务器的端口 80,并在后台运行”ssh -f -N -L 8080:远程服务器IP:80 用户名@远程服务器IP -i key.pem重启并更新Actual
Section titled “重启并更新Actual”/root/actual为本地映射路径
docker stop my_actual_budget && docker container rm my_actual_budget && docker run --pull=always --restart=unless-stopped -d -p 5006:5006 -v /root/actual:/data --name my_actual_budget actualbudget/actual-server:latest