86 lines
2.8 KiB
Nginx Configuration File
86 lines
2.8 KiB
Nginx Configuration File
# 宝塔面板 Nginx 配置 / 通用 Nginx 配置
|
||
# 注意:请勿直接覆盖宝塔生成的配置文件!
|
||
# 将此 server 块复制到宝塔对应站点(宝塔路径: /www/server/panel/vhost/nginx/trade.yuzhiran.com.conf)
|
||
#
|
||
# 部署目录结构(/www/wwwroot/trade.yuzhiran.com/):
|
||
# index.html <- 营销落地页(landing/ 产物)
|
||
# robots.txt <- landing/robots.txt
|
||
# sitemap.xml <- landing/sitemap.xml
|
||
# app/ <- uni-app H5 构建产物(base: /app/)
|
||
# workspace/ <- user-frontend 构建产物(base: /workspace/)
|
||
# admin/ <- admin-frontend 构建产物(base: /admin/)
|
||
# backend/ <- FastAPI 后端(由 supervisor/uvicorn 运行,经 /api/ 代理)
|
||
|
||
server {
|
||
listen 80;
|
||
server_name trade.yuzhiran.com;
|
||
return 301 https://$host$request_uri;
|
||
}
|
||
|
||
server {
|
||
listen 443 ssl http2;
|
||
server_name trade.yuzhiran.com;
|
||
|
||
# SSL 证书(宝塔面板中配置,或取消注释以下行)
|
||
# ssl_certificate /www/server/panel/vhost/cert/trade.yuzhiran.com/fullchain.pem;
|
||
# ssl_certificate_key /www/server/panel/vhost/cert/trade.yuzhiran.com/privkey.pem;
|
||
# ssl_protocols TLSv1.2 TLSv1.3;
|
||
# ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:!MD5;
|
||
# ssl_prefer_server_ciphers on;
|
||
|
||
root /www/wwwroot/trade.yuzhiran.com;
|
||
index index.html;
|
||
|
||
# gzip
|
||
gzip on;
|
||
gzip_min_length 1k;
|
||
gzip_comp_level 6;
|
||
gzip_types text/plain text/css text/javascript application/json application/javascript image/svg+xml;
|
||
|
||
# 营销落地页(根路径,SEO 收录主入口)
|
||
location / {
|
||
try_files $uri $uri/ /index.html;
|
||
}
|
||
|
||
# 移动端 H5(uni-app, base: /app/)
|
||
location /app/ {
|
||
try_files $uri $uri/ /app/index.html;
|
||
}
|
||
|
||
# 网页工作台(user-frontend, base: /workspace/)
|
||
location /workspace/ {
|
||
try_files $uri $uri/ /workspace/index.html;
|
||
}
|
||
|
||
# 管理后台(admin-frontend, base: /admin/)
|
||
location /admin/ {
|
||
try_files $uri $uri/ /admin/index.html;
|
||
}
|
||
|
||
# API 反向代理到后端
|
||
location /api/ {
|
||
proxy_pass http://127.0.0.1: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_read_timeout 120s;
|
||
proxy_send_timeout 120s;
|
||
proxy_http_version 1.1;
|
||
proxy_set_header Upgrade $http_upgrade;
|
||
proxy_set_header Connection "upgrade";
|
||
}
|
||
|
||
# 静态资源缓存
|
||
location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|woff2?)$ {
|
||
expires 7d;
|
||
add_header Cache-Control "public, immutable";
|
||
}
|
||
|
||
# 证书续期校验
|
||
location ~ \.well-known {
|
||
root /www/wwwroot/trade.yuzhiran.com;
|
||
allow all;
|
||
}
|
||
}
|