更新生产环境配置,修改 API 基础地址为新的域名,并在 Vite 配置中添加手动分块设置以优化构建输出。

This commit is contained in:
zyh
2025-08-27 18:56:12 +08:00
parent 1c08651831
commit 2a2ea19f0f
9 changed files with 460 additions and 2 deletions

View File

@@ -0,0 +1,83 @@
# 宝塔面板 Nginx 站点配置
# 请将以下配置添加到你的站点配置中
server {
listen 80;
server_name 2.uzi0.cc; # 你的域名
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/2.uzi0.cc; # 修改为你的实际网站根目录路径
# SSL配置如果有SSL证书
# listen 443 ssl http2;
# ssl_certificate /path/to/your/cert.pem;
# ssl_certificate_key /path/to/your/cert.key;
# 安全配置
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
# 静态资源缓存配置
location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
add_header Access-Control-Allow-Origin *;
try_files $uri =404;
}
# API代理配置 - 解决跨域问题
location /api/ {
proxy_pass http://192.140.164.137:18080/;
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;
# CORS头部设置
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
# 处理OPTIONS预检请求
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization';
add_header Access-Control-Max-Age 1728000;
add_header Content-Type 'text/plain; charset=utf-8';
add_header Content-Length 0;
return 204;
}
}
# Vue SPA 路由配置 - 关键部分!
location / {
try_files $uri $uri/ @fallback;
}
# SPA回退配置
location @fallback {
rewrite ^.*$ /index.html last;
}
# 直接指定index.html处理所有404
error_page 404 /index.html;
# 禁止访问的文件类型
location ~ /\.ht {
deny all;
}
location ~ /\. {
deny all;
}
# 宝塔面板默认的安全配置
location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) {
return 404;
}
# 宝塔面板访问日志
access_log /www/wwwlogs/2.uzi0.cc.log;
error_log /www/wwwlogs/2.uzi0.cc.error.log;
}