换了个环境测试,发现html文件访问竟然403了,逗呐?
查看Nginx的错误日志,发现有类似记录:
FastCGI sent in stderr: "Access to the script '/abc/index.html' has been denied (see security.limit_extensions)" while reading response header from upstream
后经搜索,发现php-fpm的配置中,默认security.limit_extensions只允许访问php,所以造成部分静态文件到PHP部分就出问题了。解决办法也很简单,直接修改php-fpm配置文件,将security.limit_extensions置空:
security.limit_extensions =
重启php-fpm后问题解决。
20180910 浩哥指导:Location 静态文件后缀的那行加一个html,也是可以的。
例如:
location ~ .(JPG|jpg|gif|png|jpeg|css|js|html) {
expires 5m;
rewrite ^/abc/(.*)$ /abcd/$1 break;
}
看起来这种方式更靠谱。
未经允许不得转载:阿藏博客 » Nginx报错Access to the script has been denied (see security.limit_extensions) 解决办法