Files
agent/nginx.conf
2025-10-18 01:45:48 +00:00

46 lines
1.0 KiB
Nginx Configuration File

server {
listen 80;
server_name localhost;
# Next.js项目的根目录
root /usr/share/nginx/html;
index index.html;
# 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|svg|woff|woff2|ttf|eot)$ {
expires 30d;
add_header Cache-Control "public, no-transform";
access_log off;
}
# 错误页面
error_page 404 /404.html;
error_page 500 502 503 504 /500.html;
# 禁用访问隐藏文件
location ~ /\. {
deny all;
}
}