feat(couchdb): 添加安全重写和Caddy代理配置

添加secure_rewrites配置以增强CouchDB安全性
新增Caddy代理配置文件,支持TLS和路径重写
This commit is contained in:
cnphpbb
2025-09-09 23:24:53 +08:00
parent 8c95b69f6b
commit 0aec2296ce
2 changed files with 30 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
yourdomain.com {
# 自动申请 TLS 证书
tls your_email@example.com
# CouchDB 路径路由
handle_path /couchdb/* {
# 重写路径 (去掉 /couchdb 前缀)
rewrite * /{path.trim_prefix('/couchdb')}
# 反向代理到本地 CouchDB
reverse_proxy http://localhost:5984 {
# 关键头部设置
header_up Host {http.reverse_proxy.upstream.hostport}
header_up X-Forwarded-For {client_host}
header_up X-Forwarded-Proto https
# 可选:调整超时设置
transport http {
keepalive 300s
}
}
}
# 可选:非/couchdb路径的默认响应
handle {
respond "CouchDB available at /couchdb/" 404
}
}

View File

@@ -20,6 +20,7 @@ require_valid_user = true
authentication_redirect = /_utils/session.html
[httpd]
secure_rewrites = true
# 基本认证领域
WWW-Authenticate = Basic realm="couchdb"
# 启用 CORS
@@ -36,3 +37,6 @@ headers = accept, authorization, content-type, origin, referer
methods = GET, PUT, POST, HEAD, DELETE
# CORS 预检请求缓存时间(秒)
max_age = 3600
; [daemons]
; httpd = {chttpd, start_link, [http]}