电脑爱好者之家

当前位置: 主页 > 技术知识库 >

Http403错误重现实验及解决方法

时间:2012-10-22 22:35来源:未知 作者:熊猫蜀黍 点击:
问题介绍 403是Web服务器返回的一种非常常见的错误代码,Http协议中对403错误定义如下, 403 Forbidden The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the r

问题介绍

403是Web服务器返回的一种非常常见的错误代码,Http协议中对403错误定义如下,

403 Forbidden
The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated. If the request method was not HEAD and the server wishes to make public why the request has not been fulfilled, it SHOULD describe the reason for the refusal in the entity. If the server does not wish to make this information available to the client, the status code 404 (Not Found) can be used instead.
 

而在IIS中根据具体的功能对403错误通过子错误代码的形式进行了更详细的分类。

IIS 7.0 defines the following HTTP status codes that indicate a more specific cause of a 403 error:

    403.1 - Execute access forbidden.
    403.2 - Read access forbidden.
    403.3 - Write access forbidden.
    403.4 - SSL required.
    403.5 - SSL 128 required.
    403.6 - IP address rejected.
    403.7 - Client certificate required.
    403.8 - Site access denied.
    403.9 - Forbidden: Too many clients are trying to connect to the Web server.
    403.10 - Forbidden: Web server is configured to deny Execute access.
    403.11 - Forbidden: Password has been changed.
    403.12 - Mapper denied access.
    403.13 - Client certificate revoked.
    403.14 - Directory listing denied.
    403.15 - Forbidden: Client access licenses have exceeded limits on the Web server.
    403.16 - Client certificate is untrusted or invalid.
    403.17 - Client certificate has expired or is not yet valid.
    403.18 - Cannot execute requested URL in the current application pool.
    403.19 - Cannot execute CGI applications for the client in this application pool.
    403.20 - Forbidden: Passport logon failed.
    403.21 - Forbidden: Source access denied.
    403.22 - Forbidden: Infinite depth is denied.
    403.502 - Forbidden: Too many requests from the same client IP; Dynamic IP Restriction limit reached.

 

这篇文章通过实验来重现一些常见的403错误,希望能够更加形象的演示各种错误发生的原因,并介绍相应问题的解决方法。

 

[403.1 403.3]

造成403.1 - 403.3的主要原因是由于handler需要的权限受到Handler Mapping中启用的权限的限制。

如何查看handler需要的权限?可以通过IIS Manager - Handler Mapping,根据请求的扩展名找到相应的Handler,比如我们请求.asp文件的时候报错403.3,找到处理.asp文件的handler为ASPClassic这个handler,双击打开这个handler的Script Map - Request Restrictions - Access,可以查看该handler需要的权限。在这里为了重现403.3问题,我将需要权限设置为write。

如何查看Handler Mapping启用的权限?可以通过IIS Manager - Configuration Editor打开system.webServer/handlers@accesspolicy配置节点如下,可以看到Write选项没有被选中,所以在访问asp页面的时候会出现403.3错误。另外在handler mapping中也可以看到相应的ASPClassic handler对应的状态为disabled。

403.1, 403.2的错误原因与403.3是一致的,即相应handler需要的的Script或者Read权限没有启用。

 

[403.4 403.5 403.7]

403.4, 403.5, 403.7均是由于SSL设置造成的,本身大多数时候并非服务器端错误,而是客户端的请求没有满足服务端的要求。例如

403.4是指客户端发送了一个http请求到一个配置了需要SSL的网站

403.5是指客户端发送的请求没有满足服务器对于SSL的加密位数要求

403.7是指客户端没有提供相应的证书

 

这些配置可以通过服务器端IIS Manager - SSL Setting中来配置,

 

但是对于ssl的128位数要求需要通过Configuration Editor来找到system.webServer/security/access@sslFlags来配置

 

对于403.7错误这里要说明一下,服务器如果配置了需要证书,但是客户端在正常情况下会弹出证书选择框来给用户选择用哪个证书发送给服务器。但是如果客户端在只有一张证书的情况下就不会弹选择框而直接发送给服务器。如果遇到了403.7错误,很可能是因为客户端没有找到一个可用的证书。

这里所谓的可用证书的根据服务器返回的信任列表来定义的,根据SSL协议,服务器会在SSL握手的时候返回一组服务器信任的根证书给客户端,客户端查找是否存在相应的用户证书链接自这些根证书,然后弹出选择框。所以如果这里没有找到客户端证书的话,要先确定客户端是否有相应的证书,如果没有则需要安装,如果证书存在,那么要检查其相应的根证书是否在服务器端的信任列表中。

 

[403.14]

403.14非常常见,而且原因也很简单,就是目录不允许被浏览。

 

解决方法要根据实际需求来看,

1. 如果客户请求的问题,即浏览了不该浏览的目录,那服务器不需要任何更改

2. 如果浏览的目录期待的结果应该是一个默认网页,很有可能是default document没有配好或者不在目录下

3. 如果需要启用目录浏览,则到IIS Manager到指定的目录 - Directory Browsing - Enable

 

[403.6 403.8]

这两种错误与服务器配置相关,服务器在ipSecurity配置中阻止了客户端相应的ip或者dns名字。具体的配置为system.webServer/security/ipSecurity

 

 

(责任编辑:熊猫蜀黍)
织梦二维码生成器
顶一下
(1)
20%
踩一下
(4)
80%
------分隔线----------------------------
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 验证码:点击我更换图片
栏目列表
推荐内容