HTTPS 配置
生产环境必须启用 HTTPS。PocketBase 本身不负责证书管理,推荐交给 Caddy 或 Nginx。
方案一:Caddy(推荐)
Section titled “方案一:Caddy(推荐)”Caddy 会自动申请并续期证书(Let’s Encrypt)。
api.example.com { reverse_proxy 127.0.0.1:8090}重载配置:
sudo systemctl reload caddy方案二:Nginx + Certbot
Section titled “方案二:Nginx + Certbot”-
先配置 HTTP 站点(用于 ACME 验证),并确保
api.example.com指向你的服务器。 -
申请证书:
sudo apt updatesudo apt install -y certbot python3-certbot-nginxsudo certbot --nginx -d api.example.com- 确认自动续期:
sudo systemctl status certbot.timersudo certbot renew --dry-runCloudflare 场景提醒
Section titled “Cloudflare 场景提醒”如果使用 Cloudflare 代理(橙色云):
- SSL/TLS 模式用 Full (Strict)
- Origin 也需要有效证书(Caddy/Certbot 都可)