40 lines
1.1 KiB
Plaintext
40 lines
1.1 KiB
Plaintext
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
|
|
# 静态文件访问:匹配 /api/v1/common/files/ 路径
|
|
# 使用 alias 直接映射到本地文件系统
|
|
location /api/v1/common/files/ {
|
|
# 去掉前缀 /api/v1/common/files/,映射到 /app/uploads/
|
|
alias /app/uploads/;
|
|
|
|
# 尝试文件,找不到返回 404
|
|
try_files $uri =404;
|
|
|
|
# 关闭日志以提升性能(可选)
|
|
# access_log off;
|
|
|
|
# 设置合适的 MIME 类型
|
|
include /etc/nginx/mime.types;
|
|
}
|
|
|
|
# 其他所有请求,反向代理到 Flask 后端
|
|
location / {
|
|
proxy_pass http://backend:8000;
|
|
|
|
# 设置代理请求头
|
|
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;
|
|
|
|
# 超时设置
|
|
proxy_connect_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
proxy_read_timeout 60s;
|
|
|
|
# 启用 HTTP/1.1
|
|
proxy_http_version 1.1;
|
|
}
|
|
}
|