【问题标题】:IIS Bad Request for the site configured with url-rewrite with ARR对配置了带有 ARR 的 url-rewrite 的站点的 IIS 错误请求
【发布时间】:2019-05-15 07:51:24
【问题描述】:

我在 Windows 2012 的 IIS 8.0 下创建了网站。在此站点下创建了一个使用 ARR 重写的 URL,它指向一台 linux 机器(基本上指向部署在 Tomcat 中的 Web 服务),并且通过 IIS 将有“GET”请求,其中URL 与查询字符串一起超过 5000 个字符。当通过程序或浏览器访问 URL 时,我看到 IIS 抛出“错误请求”,状态代码为 400,没有子状态代码。当它直接访问 web 服务(对于 tomcat Linux)时,同样有效。我怀疑这个问题是因为 url 中的字符过多,因为当我尝试将 url 长度减少到 3500 个字符时,它没有任何错误。以下是我在 IIS web.config 和 http.sys 注册表中尝试过的配置和设置,但似乎没有任何效果。

<configuration>
    <system.webServer>
        <security>
            <requestFiltering allowDoubleEscaping="true">
                <requestLimits maxAllowedContentLength="4294967295" maxUrl="10999" maxQueryString="2097151">
                    <headerLimits>
                        <add header="Content-Type" sizeLimit="100000000" />
                    </headerLimits>
                </requestLimits>
            </requestFiltering>
        </security>
        <urlCompression doDynamicCompression="false" />
    </system.webServer>
    <system.web>
        <httpRuntime maxRequestLength="8192" maxUrlLength="8192" maxQueryStringLength="8192" requestPathInvalidCharacters="" />
    </system.web>
</configuration>

http.sys 注册表设置

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\MaxFieldLength - DWORD - 65534
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\MaxRequestBytes - DWORD - 16777216
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\UrlSegmentMaxCount - DWORD - 16383
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters\UrlSegmentMaxLength - DWORD - 32766

在完成上述所有设置和配置后,我已经重新启动了 Windows 服务器。

IIS 支持这些设置和配置,无需重写 url。如果我为同一网站尝试其他长度为 5000 个字符的 url,它的工作原理没有任何错误。这仅出现在 URL 重写配置下的 url。除了上面提到的 ARR 中的 URL 长度是否需要进行任何特定的配置?请建议和帮助。 提前致谢。

【问题讨论】:

    标签: windows iis iis-8 url-rewrite-module arr


    【解决方案1】:

    回答我的问题。

    问题出在 Linux Tomcat 端而不是 IIS 端,catalina.out 日志如下所示

    INFO: Error parsing HTTP request header
     Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level.
    java.lang.IllegalArgumentException: Request header is too large
    

    我在tomcat/conf的server.xml中添加了maxHttpHeaderSize="65536"的配置。修改后,问题解决了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-21
      • 2017-05-08
      • 2017-07-09
      • 1970-01-01
      • 2016-12-07
      • 2021-05-22
      • 2012-12-19
      相关资源
      最近更新 更多