All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
- 重新组织location块并添加清晰的分区注释 - 新增多个API接口的代理配置 - 修正client_max_body_size的注释说明 - 保持原有功能不变的情况下提高配置可读性
142 lines
5.9 KiB
Nginx Configuration File
142 lines
5.9 KiB
Nginx Configuration File
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
include /etc/nginx/mime.types;
|
|
default_type application/octet-stream;
|
|
client_max_body_size 10G; # 允许的最大文件大小为 10GB
|
|
|
|
server {
|
|
listen 3001;
|
|
server_name localhost;
|
|
|
|
# ============================================
|
|
# 用户认证相关接口 (/user-api/*)
|
|
# ============================================
|
|
location /user-api/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass http://localhost:33333/user/;
|
|
}
|
|
|
|
# ============================================
|
|
# 文件服务接口 (/file/*)
|
|
# ============================================
|
|
location /file/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass http://localhost:33333/file/;
|
|
}
|
|
|
|
# ============================================
|
|
# Story 相关接口 (/api/story/*)
|
|
# ============================================
|
|
location /api/story/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass http://localhost:33333/story/;
|
|
}
|
|
|
|
# ============================================
|
|
# 用户服务接口 (/api/user/*)
|
|
# 包含: 用户资料、偏好设置、相册、集合等
|
|
# ============================================
|
|
location /api/user/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass http://localhost:33333/user/;
|
|
}
|
|
|
|
# ============================================
|
|
# API v1 版本接口 (/api/v1/*)
|
|
# 包含: 评论、点赞、同步、统计等
|
|
# ============================================
|
|
location /api/v1/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass http://localhost:33333/user/api/v1/;
|
|
}
|
|
|
|
# ============================================
|
|
# 地理信息接口 (/api/geographic/*)
|
|
# ============================================
|
|
location /api/geographic/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass http://localhost:33333/api/geographic/;
|
|
}
|
|
|
|
# ============================================
|
|
# 通用 API 接口 (/api/*)
|
|
# 用于其他未明确配置的 API 路径
|
|
# ============================================
|
|
location /api/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header Authorization $http_authorization;
|
|
proxy_pass http://localhost:33333/api/;
|
|
}
|
|
|
|
# ============================================
|
|
# MinIO 对象存储代理
|
|
# 需要在后端配置 minio.externalEndpoint 为 http://<domain>/minio
|
|
# ============================================
|
|
location /minio/ {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_pass http://localhost:9000/;
|
|
}
|
|
|
|
# ============================================
|
|
# 前端静态资源
|
|
# ============================================
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html index.htm;
|
|
try_files $uri $uri/ /index.html; # 用于处理 SPA 路由
|
|
}
|
|
|
|
error_page 500 502 503 504 /50x.html;
|
|
location = /50x.html {
|
|
root /usr/share/nginx/html;
|
|
}
|
|
}
|
|
}
|