This commit is contained in:
2025-10-18 01:45:48 +00:00
parent 189f20fdac
commit 9a1148e1bc
4 changed files with 3752 additions and 19 deletions

View File

@ -2,18 +2,37 @@ server {
listen 80;
server_name localhost;
# Next.js项目的根目录
root /usr/share/nginx/html;
index index.html;
# 支持Next.js路由
# Next.js路由配置
location / {
try_files $uri $uri/ /index.html;
}
# 处理Next.js静态资源
location /_next/ {
alias /usr/share/nginx/html/_next/;
expires 30d;
access_log off;
}
# 处理API路由
location /api/ {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# 静态文件缓存
location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ {
location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
access_log off;
}
# 错误页面