feat(caddy): 支持分销站点独立域名 On-Demand TLS 自动签发 SSL 证书
- 后端新增 GET /api/distribution/check-domain 作为 Caddy on_demand_tls ask 白名单端点 - 补充 CheckDomain 相关场景自动化测试 - Caddyfile 启用 on_demand_tls 并配置动态分销前台入口
This commit is contained in:
@@ -378,6 +378,27 @@ func (h *Handler) GetPublicSiteInfo(c *gin.Context) {
|
||||
response.OK(c, info)
|
||||
}
|
||||
|
||||
// CheckDomain 供网关(如 Caddy on_demand_tls ask)在按需申请 SSL 证书时校验域名白名单。
|
||||
// 仅当域名属于系统中正常运行(active)的分销站点时返回 200,其余情况返回 404,
|
||||
// 防止任意外部未授权域名解析到该服务器刷爆 Let's Encrypt 证书申请配额。
|
||||
func (h *Handler) CheckDomain(c *gin.Context) {
|
||||
domain := strings.ToLower(strings.TrimSpace(c.Query("domain")))
|
||||
if domain == "" {
|
||||
c.String(http.StatusBadRequest, "domain required")
|
||||
return
|
||||
}
|
||||
if colon := strings.Index(domain, ":"); colon != -1 {
|
||||
domain = domain[:colon]
|
||||
}
|
||||
|
||||
info, err := h.service.GetPublicSiteInfo(c.Request.Context(), "", domain)
|
||||
if err != nil || info == nil || info.Status != "active" {
|
||||
c.String(http.StatusNotFound, "domain not allowed")
|
||||
return
|
||||
}
|
||||
c.String(http.StatusOK, "ok")
|
||||
}
|
||||
|
||||
func (h *Handler) ListPaymentChannels(c *gin.Context) {
|
||||
siteID := parseQueryUint(c, "site_id")
|
||||
if siteID <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user