Files
yierp-v16/docker/docs/03-production/05-caddy-https.md
T
2026-10-18 03:39:07 +08:00

48 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: Caddy 与 HTTPS
---
# Caddy 反向代理(本地 HTTPS)
本指南说明如何使用 Caddy 作为 frontend 容器前的外部反向代理。它最适用于本地 HTTPS 或内部网络。
## 前置条件
- 在主机端口上暴露 frontend 容器(默认 8080)
- 将本地域名添加到 hosts 文件(或使用内部 DNS)
- 安装 Caddy
## 步骤 1:暴露 frontend 服务
包含 no-proxy 覆盖文件,使 frontend 在主机上可访问:
```sh
docker compose -f compose.yaml \
-f overrides/compose.mariadb.yaml \
-f overrides/compose.redis.yaml \
-f overrides/compose.noproxy.yaml \
config > ~/gitops/docker-compose.yml
docker compose --project-name <project-name> -f ~/gitops/docker-compose.yml up -d
```
如果你更改了 HTTP 端口,请记下 `HTTP_PUBLISH_PORT` 的值以用于下一步。
## 步骤 2:配置 Caddy
将站点块添加到你的 Caddyfile(通常是 `/etc/caddy/Caddyfile`):
```caddy
erp.localdev.net {
tls internal
reverse_proxy localhost:8080
}
```
如果你更改了发布的 frontend 端口,请将 `8080` 替换为你的端口。
## 步骤 3:信任 Caddy 根证书
使用 `tls internal` 时,Caddy 从其内部 CA 颁发证书。在任何需要访问站点的客户端上导入并信任 Caddy 根证书。
另见:[TLS/SSL 配置总览](01-tls-ssl-setup.md)。