在请求如 /_next/static/media/page-main-image.0b61c706.png 这样的文件时
这段配置可以正常运行
location ~* /_next/static/.*(js|css|png|jpg|jpeg|svg|gif|ico|ttf|webp)$ {
rewrite /_next/(.*) /.next/$1 break;
try_files $uri $uri/;
expires 1y; # 设置缓存时间为 1 年
add_header Cache-Control "public";
}
这段配置却找不到文件、响应体还会变成 308 重定向
location ~* /_next/static/.*(js|css|png|jpg|jpeg|svg|gif|ico|ttf|webp)$ {
alias /app/.next/static/; # 将请求路径 /_next/static/ 映射到文件系统的 /app/.next/static/
expires 1y; # 设置缓存时间为 1 年
add_header Cache-Control "public";
}
1
proxytoworld 18 小时 43 分钟前
用 ai 解释就行了,刚试了一下。
|
2
newaccount 18 小时 9 分钟前
break
开 debug 看其他配置 这标题懒得认真答 |
3
wogogoing 11 小时 3 分钟前
把:
alias /app/.next/static/; 改为: root /app/.next/static/; autoindex off; 试一下吧,我没记错的话,应该可以。 |