NGINX 代码报错:location = / 语法错误及修正
这段 Nginx 代码有语法错误,应该改为以下代码:
location = / {
if ($cookie_safe != '') {
proxy_pass http://127.0.0.1;
proxy_set_header Host $host;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
if ( $uri ~* '\.(gif|png|jpg|css|js|woff|woff2|ico)$' ) {
expires 365d;
}
proxy_ignore_headers Set-Cookie Cache-Control expires;
proxy_cache my_cache;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 301 302 5s;
}
try_files /123.html =200;
}
改动包括:
- 将 try_files 和 return 200 合并为 try_files /123.html =200;
- 将 try_files 放在 if 语句内
- 在 try_files 后添加 }
原文地址: https://www.cveoy.top/t/topic/n4l1 著作权归作者所有。请勿转载和采集!