5a1af9f82f
- Add deploy/ directory with production env, supervisor, nginx, migration configs - Include all latest features: admin management, feedback, footer with ICP/beian - Database: foreign_trade (PostgreSQL), user: foreign_trade - Frontend: trade.yuzhiran.com, backend proxy via Nginx
71 lines
2.2 KiB
Nginx Configuration File
71 lines
2.2 KiB
Nginx Configuration File
# 宝塔面板 Nginx 配置
|
|
# 注意:请勿直接覆盖宝塔生成的配置文件!
|
|
# 将此配置中的 server 块复制到宝塔对应站点的配置中
|
|
# 宝塔路径: /www/server/panel/vhost/nginx/trade.yuzhiran.com.conf
|
|
|
|
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.1 TLSv1.2 TLSv1.3;
|
|
# ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
|
|
# ssl_prefer_server_ciphers on;
|
|
|
|
# 前端静态文件(uni-app build:h5 产物)
|
|
root /www/wwwroot/trade.yuzhiran.com/frontend/dist;
|
|
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;
|
|
|
|
# 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;
|
|
|
|
# WebSocket 支持(如有需要)
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
}
|
|
|
|
# 上传文件(如有需要可配置单独的路径)
|
|
# location /uploads/ {
|
|
# alias /www/wwwroot/trade.yuzhiran.com/backend/uploads/;
|
|
# expires 7d;
|
|
# }
|
|
|
|
# SPA 路由 fallback
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# 静态资源缓存
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
expires 30d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# 禁止访问隐藏文件
|
|
location ~ /\. {
|
|
deny all;
|
|
}
|
|
}
|