一个奇葩常见的问题 nginx 403 forbidden错误

今天安装dedecms,配置Nginx,然后生成一键生成静态页面,然后就没有然后了,所有栏目页面都显示nginx 403 forbidden。

一般来说nginx 的 403 Forbidden errors 表示你在请求一个资源文件但是nginx不允许你查看。
403 Forbidden 只是一个HTTP状态码,像404,200一样不是技术上的错误。
哪些场景需要返回403状态码的场景?
1.网站禁止特定的用户访问所有内容,例:网站屏蔽某个ip访问。
2.访问禁止目录浏览的目录,例:设置autoindex off后访问目录。
3.用户访问只能被内网访问的文件。
以上几种常见的需要返回 403 Forbidden 的场景。

一、权限配置不正确

不应该啊,查看了一下nginx.conf头部使用use nginx。网上很多人说改成root也是醉了,其实栏目目录对于nginx用户是可读的,这根本不是问题所在。

二、目录索引设置错误(index指令配置)

由于dedecms是PHP程序,当时也没注意配置如下
index index.php;
然后悲剧的事情就发生了,栏目下根本就没有php文件啊,只有index.html。
当访问该网站的时,nginx 会按照index.php 的先后顺序(当然这里就一个)在根目录中查找文件。如果这个文件不存在(显然不存在啊),那么nginx就会返回403 Forbidden。

于是配置成index index.html index.htm index.php;

然后nginx -s relaod 重启一下就好了。

时间: 2024-08-09 10:42:56

一个奇葩常见的问题 nginx 403 forbidden错误的相关文章

nginx “403 Forbidden” 错误的原因及解决办法

nginx 的 403 Forbidden errors 表示你在请求一个资源文件但是nginx不允许你查看. 403 Forbidden 只是一个HTTP状态码,像404,200一样不是技术上的错误. 哪些场景需要返回403状态码的场景? 1.网站禁止特定的用户访问所有内容,例:网站屏蔽某个ip访问. 2.访问禁止目录浏览的目录,例:设置autoindex off后访问目录. 3.用户访问只能被内网访问的文件. 以上几种常见的需要返回 403 Forbidden 的场景. 由于服务器端的错误配

laravel部署在nginx 出现 nginx 403 forbidden 错误的处理

laravel部署在nginx 总是出现 nginx 403 forbidden 如果不是权限问题,也不是索引文件的问题.那就是,laravel的主目录指定错了.原来不能指定laravel程序的根目录.要指定在public目录. Nginx 服务器 location / { try_files $uri $uri/ /index.php?$query_string; } 版权声明:本文为博主原创文章,未经博主允许不得转载.

Nginx 403 Forbidden错误的解决方法

解决方法是在nginx.conf配置文件中,配置 user root; 然后 sudo /usr/local/nginx/sbin/nginx -s reload 问题解决就解决了 原文地址:https://www.cnblogs.com/Hannibal-2018/p/11183800.html

demopu教你Nginx 403 forbidden的解决办法

来自:http://www.demopu.com/?p=639 常见的,引起nginx 403 forbidden有二种原因,一是缺少索引文件,二权限问题.1,缺少index.html或者index.php文件[plain]view plaincopyserver {        listen       80;        server_name  localhost;        index  index.php index.html;        root  /var/www;  

Apache2.4部署django出现403 Forbidden错误解决办法

前言:Apache部署django出现403 Forbidden错误最好要结合apache中的错误日志来观察出现何种错误导致出现403错误 下午百度了一下午没找到解决办法,试了n种方法,简直坑爹! 比如网页出现最多的解决办法是: <Directory E:/wamp/Apache24/www(你的工程路径)>           Order allow,deny           Allow from all       </Directory> 可惜这样改了后还是报403,最后

Nginx 403 forbidden多种原因及故障模拟重现

访问Nginx出现状态码为403 forbidden原因及故障模拟 1) nginx配置文件里不配置默认首页参数或者首页文件在站点目录下没有 1 index index.php index.html index.htm; 问题模拟示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [[email protected] extra]# cat www.conf #www virtualhost by oldboy    server 

Nginx 403 forbidden原因及故障模拟重现

访问Nginx出现状态码为403 forbidden原因及故障模拟 1) nginx配置文件里不配置默认首页参数或者首页文件在站点目录下没有 index index.php index.html index.htm; 问题模拟示例: [[email protected] extra]# cat www.conf #www virtualhost by oldboy    server {        listen       80;        server_name  www.etiant

nginx静态资源文件无法访问,403 forbidden错误

版权声明:本文为博主原创文章,未经博主允许不得转载. 今天在搭建nginx环境时出现一个奇怪问题,配置的静态资源目录下面文件无法访问,浏览器访问出现403 forbidden,环境是centos7 + nginx 1.6.nginx.conf中http配置如下: [plain] view plain copy -- http { include       mime.types; default_type  application/octet-stream; sendfile        on

Nginx 403 forbidden的解决办法

以下是我的Nginx配置: user root; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/oct