OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 1933|回复: 1

解决Nginx出现 403 Forbidden的办应该怎样做

[复制链接]

153

主题

311

帖子

0

精华

高级会员

Rank: 4

积分
673
金钱
673
注册时间
2019-3-26
在线时间
18 小时
发表于 2019-4-23 16:26:22 | 显示全部楼层 |阅读模式
Nginx 也是当前流行的一款轻量级服务器在日常使用中呢,也会出现一些问题。在安装配置Nginx的时候就出现了 403 Forbindden 的被禁止访问的错误该怎么解决呢?这里给大家分享下
  话不多说 先粘 上 原版nginx 配置文件代码
  worker_processes 1;
  events {
  worker_connections 1024;
  }
  http {
  include mime.types;
  default_type application/octet-stream;
  sendfile on;
  autoindex on;
  keepalive_timeout 65;
  fastcgi_connect_timeout 300;
  fastcgi_send_timeout 300;
  fastcgi_read_timeout 300;
  fastcgi_buffer_size 128k;
  fastcgi_buffers 4 128k;
  fastcgi_busy_buffers_size 256k;
  fastcgi_temp_file_write_size 256k;
  #gzip on;
  gzip on;
  gzip_min_length 1k;
  gzip_buffers 4 32k;
  gzip_http_version 1.1;
  gzip_comp_level 2;
  gzip_types text/plain application/x-javascript text/css application/xml;
  gzip_vary on;
  gzip_disable “MSIE [1-6].”;
  server_names_hash_bucket_size 128;
  client_max_body_size 100m;
  client_header_buffer_size 256k;
  large_client_header_buffers 4 256k;
  server {
  listen 80;
  server_name localhost;
  autoindex on; #是否允许访问目录
  root “C:/WWW”;
  location / {
  index index.html index.htm l.php;
  #index.php
  autoindex on;
  }
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
  root html;
  }
  location —— .php(.)$ {
  fastcgi_pass 127.0.0.1:9000;
  #fastcgi_index index.php;
  fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
  fastcgi_param SCRIPT_FILENAME <span class="MathJax" id="MathJax-Element-1-Frame" tabindex="0" data-mathml="documentroot      document_root" role="presentation" style="box-sizing: border-box; outline: 0px; display: inline; line-height: normal; word-spacing: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">documentrootdocument_rootdocumentr&#8203;ootfastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;
  fastcgi_param PATH_TRANSLATED <span class="MathJax" id="MathJax-Element-2-Frame" tabindex="0" data-mathml="documentroot      document_root" role="presentation" style="box-sizing: border-box; outline: 0px; display: inline; line-height: normal; word-spacing: normal; white-space: nowrap; float: none; direction: ltr; max-width: none; max-height: none; min-width: 0px; min-height: 0px; border: 0px; position: relative;">documentrootdocument_rootdocumentr&#8203;ootfastcgi_path_info;
  include fastcgi_params;
  }
  }
  include vh_
.conf;
  }
  这么多配置文件代码(为了便于查看 已经把注释的那些不懂的删除) 学习君也是看不懂的
  先说403 出现的原因
  当访问该地址的时候,nginx 会按照 index.html,index.htm ,index.PHP 的先后顺序在根目录中查找文件。VPS云主机如果这三个文件都不存在,那么nginx就会返回403 Forbidden。
  学习君根目录下也是没有这三个文件的 所以直接
  root “C:/WWW”;
  location / {
  index index.html index.htm l.php;
  #index.php
  autoindex on;
  }
  注释 项目列表就展示出来了
  这里要注意
  autoindex on; 这个默认是off的 意思是禁止访问目录 需要开启
  还有一点推荐大家别把配置项 都写在这个文件当中 不便于管理
  include vh_*.conf;
  可以引入这样一个域名一个配置文件方便管理

http://www.iis7.com/c/90/
正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

头像被屏蔽

64

主题

234

帖子

0

精华

禁止访问

积分
603
金钱
603
注册时间
2017-11-13
在线时间
71 小时
发表于 2019-4-23 16:31:16 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-6-9 06:28

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表