请知悉:本文最近一次更新为 6年 前,文中内容可能已经过时。

换了个环境测试,发现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) 解决办法》相关的博文:


发布时间 08/26/2018 16:36:50栏目 Software.标签 .

留言

avatar
😀
😀😁😂😅😭🤭😋😘🤔😰😱🤪💪👍👎🤝🌹👌