diff --git a/backend/Dockerfile b/backend/Dockerfile index 3eb041b..2e1fe86 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,13 +2,13 @@ FROM golang:1.26-alpine AS builder RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories -RUN apk add --no-cache git +RUN apk add --no-cache git gcc musl-dev WORKDIR /src COPY go.mod go.sum ./ RUN go env -w GOPROXY=https://goproxy.cn,direct && go mod download COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/gen2d ./cmd/main.go +RUN CGO_ENABLED=1 GOOS=linux go build -o /bin/gen2d ./cmd/main.go # ---- Runtime Stage ---- FROM alpine:3.20 diff --git a/docs/api.md b/docs/api.md index 2a508ee..5c6f9ba 100644 --- a/docs/api.md +++ b/docs/api.md @@ -57,7 +57,7 @@ Token 过期或无效时返回: ## 用户认证 -> **注意:** 后端代码实际注册路径为 `/auth/*`(非 `/api/v1/auth/*`),前端 Vite 代理已配置 `/auth` 转发。 +> **注意:** 后端代码实际注册路径为 `/auth/*`(非 `/api/v1/auth/*`),前端 Vite 代理及 nginx 均已配置 `/auth` 转发。 | 状态 | 方法 | 路径 | 说明 | |------|------|------|------| diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 6eb4544..0a6a0c8 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -18,4 +18,13 @@ server { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + + # 反向代理 /auth 到后端服务 + location /auth/ { + proxy_pass http://backend:8080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } }