refactor(nginx): 重构nginx配置并添加详细注释
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
All checks were successful
test/timeline-frontend/pipeline/head This commit looks good
- 重新组织location块并添加清晰的分区注释 - 新增多个API接口的代理配置 - 修正client_max_body_size的注释说明 - 保持原有功能不变的情况下提高配置可读性
This commit is contained in:
86
nginx.conf
86
nginx.conf
@@ -5,11 +5,15 @@ events {
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
client_max_body_size 10G; # 允许的最大文件大小为 20MB
|
||||
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;
|
||||
@@ -20,6 +24,10 @@ http {
|
||||
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;
|
||||
@@ -29,8 +37,12 @@ http {
|
||||
proxy_set_header X-Forwarded-Port $server_port;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
proxy_pass http://localhost:33333/file/;
|
||||
}
|
||||
location /api/story/ {
|
||||
}
|
||||
|
||||
# ============================================
|
||||
# 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;
|
||||
@@ -38,11 +50,72 @@ http {
|
||||
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/story/;
|
||||
}
|
||||
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;
|
||||
@@ -51,6 +124,9 @@ http {
|
||||
proxy_pass http://localhost:9000/;
|
||||
}
|
||||
|
||||
# ============================================
|
||||
# 前端静态资源
|
||||
# ============================================
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
|
||||
Reference in New Issue
Block a user