优化客服云权限安全与访客IP解析

This commit is contained in:
yml2213
2026-08-31 13:43:45 +08:00
parent 523a306d5e
commit bdf67395ab
24 changed files with 365 additions and 48 deletions
+1
View File
@@ -24,6 +24,7 @@ DB_SSLMODE=disable
# ========== JWT(deploy.sh 可自动生成)==========
JWT_SECRET=请改成随机长字符串
CORS_ALLOW_ORIGINS=https://你的域名
# ========== MinIO 对象存储 ==========
STORAGE_ACCESS_KEY=kefu_minio
+6
View File
@@ -155,6 +155,12 @@ STORAGE_PUBLIC_BASE_URL=https://kefu.example.com/files
## HTTPS 其它方式
### 访客 IP 显示说明
本地通过 Docker 网桥访问时,访客 IP 可能显示为 `172.19.0.1`;直接在本机开发服务访问时则常见为 `127.0.0.1` 或 `::1`,这两种都表示本地回环/网桥地址,不是公网 IP。
生产链路由 Caddy → 应用 Nginx → API 时,API 优先读取 `X-Forwarded-For` 最左侧地址,`X-Real-IP` 仅作为回退,因此外部访客会显示其公网地址。请保持示例反代配置中的 `X-Forwarded-For` 转发,不要在边缘代理处清空该请求头。
任选其一(与上一节「Caddy 共存」二选一即可):
1. **CLB / CDN** 终结 HTTPS,回源 CVM `HTTP_PORT`(或仍回源 Caddy)
+1 -1
View File
@@ -8,7 +8,7 @@
# docker build --build-arg ALPINE_MIRROR=dl-cdn.alpinelinux.org \
# --build-arg GOPROXY=https://proxy.golang.org,direct ...
FROM golang:1.24-alpine AS builder
FROM golang:1.26-alpine AS builder
ARG ALPINE_MIRROR=mirrors.cloud.tencent.com
ARG GOPROXY=https://goproxy.cn,direct
+2 -2
View File
@@ -45,7 +45,7 @@ need_cmd() {
if ! command -v "$1" >/dev/null 2>&1; then
err "缺少命令: $1"
case "$1" in
go) err "请安装 Go 1.22+:https://go.dev/dl/ 或 brew install go" ;;
go) err "请安装 Go 1.26+:https://go.dev/dl/ 或 brew install go" ;;
node|npm) err "请安装 Node.js 20+:https://nodejs.org/ 或 brew install node" ;;
docker) err "请安装 Docker Desktop for Mac:https://www.docker.com/products/docker-desktop/" ;;
esac
@@ -118,7 +118,7 @@ check_prereqs() {
go_major="$(go env GOVERSION 2>/dev/null | sed -E 's/^go([0-9]+).*/\1/' || echo 0)"
go_minor="$(go env GOVERSION 2>/dev/null | sed -E 's/^go[0-9]+\.([0-9]+).*/\1/' || echo 0)"
if [[ "${go_major:-0}" -lt 1 ]] || { [[ "${go_major:-0}" -eq 1 && "${go_minor:-0}" -lt 22 ]]; }; then
warn "建议 Go 1.22+,当前: $(go version 2>/dev/null || echo unknown)"
warn "建议 Go 1.26+,当前: $(go version 2>/dev/null || echo unknown)"
fi
local node_major