优化更新
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
# DjangoAdmin Nginx 反向代理配置
|
||||
# 部署时修改 server_name、root、proxy_pass 为实际值
|
||||
|
||||
upstream fastapi_backend {
|
||||
server 127.0.0.1:8031;
|
||||
keepalive 16;
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name your-domain.com;
|
||||
|
||||
charset utf-8;
|
||||
client_max_body_size 50m;
|
||||
|
||||
# 安全头
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
|
||||
# Gzip
|
||||
gzip on;
|
||||
gzip_min_length 1k;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css application/json application/javascript text/xml image/svg+xml;
|
||||
gzip_vary on;
|
||||
|
||||
# 前端静态资源
|
||||
root /data/apps/djangoadmin/frontend/dist;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /assets/ {
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# API 反向代理
|
||||
location /api/ {
|
||||
proxy_pass http://fastapi_backend/api/;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
# 透传上游X-Forwarded-For(不追加本机IP);无上游头时回退到直连IP
|
||||
proxy_set_header X-Forwarded-For $http_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Connection "";
|
||||
proxy_connect_timeout 60s;
|
||||
proxy_read_timeout 120s;
|
||||
proxy_send_timeout 60s;
|
||||
}
|
||||
|
||||
# 上传文件访问
|
||||
location /api/file/ {
|
||||
alias /data/apps/djangoadmin/uploads/;
|
||||
expires 7d;
|
||||
access_log off;
|
||||
limit_except GET { deny all; }
|
||||
}
|
||||
|
||||
# 禁止访问隐藏文件
|
||||
location ~ /\. { deny all; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
; Supervisor 进程管理示例配置
|
||||
; 将 command / directory 替换为实际路径后复制到 /etc/supervisor/conf.d/
|
||||
|
||||
[program:djangoadmin-fastapi]
|
||||
; 启动命令:使用项目虚拟环境中的 uvicorn
|
||||
command=/path/to/venv/bin/uvicorn src.main:app --host 127.0.0.1 --port 8031
|
||||
; 项目根目录
|
||||
directory=/path/to/DjangoAdmin_FastAPI_EleVue
|
||||
autostart=true
|
||||
autorestart=true
|
||||
stopasgroup=true
|
||||
killasgroup=true
|
||||
redirect_stderr=true
|
||||
stdout_logfile=/path/to/logs/supervisor.out.log
|
||||
stdout_logfile_maxbytes=50MB
|
||||
stdout_logfile_backups=10
|
||||
environment=PYTHONUNBUFFERED=1
|
||||
Reference in New Issue
Block a user