123
This commit is contained in:
23
nginx.conf
23
nginx.conf
@ -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;
|
||||
}
|
||||
|
||||
# 错误页面
|
||||
|
||||
Reference in New Issue
Block a user