修改环境变量在nginx部署
parent
b4a88fcba6
commit
52e22970bc
|
|
@ -3,7 +3,7 @@ NODE_ENV=production
|
|||
|
||||
VITE_DEV=false
|
||||
|
||||
# 请求路径
|
||||
# 请求路径(修改为实际的后端服务地址,如果前后端在同一服务器,可以使用相对路径或当前域名)
|
||||
VITE_BASE_URL='http://localhost:48080'
|
||||
|
||||
# 文件上传类型:server - 后端上传, client - 前端直连上传,仅支持S3服务
|
||||
|
|
|
|||
|
|
@ -0,0 +1,101 @@
|
|||
# Nginx 配置文件 - 前后端同服务器部署
|
||||
# 适用于 Vue3 前端 + 后端 API 部署在同一台服务器
|
||||
|
||||
server {
|
||||
listen 3080; # 前端服务端口
|
||||
# 请根据实际情况修改域名,如果没有域名可以使用服务器IP
|
||||
server_name your-domain.com; # 修改为你的域名或服务器IP
|
||||
|
||||
# 前端静态文件根目录 - 构建后的 dist 目录
|
||||
root /var/www/ncc-ui-admin-vue3/dist; # 修改为实际的部署路径
|
||||
index index.html;
|
||||
|
||||
# 开启 gzip 压缩
|
||||
gzip on;
|
||||
gzip_vary on;
|
||||
gzip_min_length 1024;
|
||||
gzip_comp_level 6;
|
||||
gzip_types text/plain text/css text/xml text/javascript application/json application/javascript application/xml+rss application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml;
|
||||
gzip_disable "msie6";
|
||||
|
||||
# 静态资源缓存策略
|
||||
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
||||
expires 7d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
access_log off;
|
||||
}
|
||||
|
||||
# 后端 API 代理配置
|
||||
location /admin-api/ {
|
||||
# 代理到后端服务,请根据实际后端端口修改
|
||||
proxy_pass http://localhost:48080/admin-api/; # 修改为实际的后端地址和端口
|
||||
|
||||
# 代理请求头设置
|
||||
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;
|
||||
|
||||
# WebSocket 支持(如果后端有 WebSocket 需求)
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
|
||||
# 超时设置
|
||||
proxy_connect_timeout 600;
|
||||
proxy_send_timeout 600;
|
||||
proxy_read_timeout 600;
|
||||
send_timeout 600;
|
||||
|
||||
# 请求体大小限制(根据需要调整,例如文件上传)
|
||||
client_max_body_size 100M;
|
||||
}
|
||||
|
||||
# 前端路由配置 - Vue Router history 模式支持
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
# 安全头部设置
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
|
||||
# 错误页面
|
||||
error_page 404 /index.html;
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
}
|
||||
|
||||
# HTTPS 配置示例(如果需要 SSL 证书)
|
||||
# server {
|
||||
# listen 443 ssl http2;
|
||||
# server_name your-domain.com;
|
||||
#
|
||||
# # SSL 证书路径
|
||||
# ssl_certificate /path/to/your/certificate.crt;
|
||||
# ssl_certificate_key /path/to/your/private.key;
|
||||
#
|
||||
# # SSL 配置
|
||||
# ssl_protocols TLSv1.2 TLSv1.3;
|
||||
# ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
# ssl_prefer_server_ciphers on;
|
||||
# ssl_session_cache shared:SSL:10m;
|
||||
# ssl_session_timeout 10m;
|
||||
#
|
||||
# # 其他配置与上面的 HTTP 配置相同
|
||||
# root /var/www/ncc-ui-admin-vue3/dist;
|
||||
# index index.html;
|
||||
#
|
||||
# # ... 复制上面的 location 配置 ...
|
||||
# }
|
||||
#
|
||||
# # HTTP 自动跳转到 HTTPS
|
||||
# server {
|
||||
# listen 80;
|
||||
# server_name your-domain.com;
|
||||
# return 301 https://$server_name$request_uri;
|
||||
# }
|
||||
14017
pnpm-lock.yaml
14017
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue