【问题标题】:IIS Header too longIIS 标头太长
【发布时间】:2020-07-16 11:39:09
【问题描述】:

我使用了很多声明并将它们存储在令牌中。我之前只是在招摇时遇到过这个错误,清除缓存总是对我有用。但是,现在我在生产环境中看到了这个错误。给出此错误的当前“授权”标头约为 16kb。我试图增加 IIS 中的“授权”标头大小,将这些添加到 web.config

<system.web>
        <httpRuntime maxRequestLength="500000000"  executionTimeout="120" />
    </system.web>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
<security>
          <requestFiltering>
            <requestLimits maxAllowedContentLength="500000000" />
          </requestFiltering>
        </security>

并在 Kestrel 中添加了尝试增加的限制:

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
            WebHost.CreateDefaultBuilder(args)
                .UseStartup<Startup>()
            .ConfigureKestrel((context, options) =>
            {
                options.Limits.MaxRequestHeadersTotalSize = 1048576;
            });
    }

以上都没有帮助。没找到其他解决方案,这里还有什么办法?

【问题讨论】:

  • support.microsoft.com/en-us/help/820129/… 传入的 HTTP 请求由 http.sys 检查,并且标头有大小限制。
  • 谢谢。有没有办法让它超过64kb?如果您将此作为答案发布,我会接受。
  • @LexLi ,给我一个机会,让我试试。 (^.^)
  • 如果@LexLi 没问题,我会接受你的回答

标签: asp.net-core iis


【解决方案1】:

正如Lex Li 所说。
根据 MSDN,
https://support.microsoft.com/en-us/help/820129/http-sys-registry-settings-for-windows
我们可以尝试在下面的注册位置设置MaxRequestBytes 属性。

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\HTTP\Parameters

如果该属性不存在,则创建并设置它。

注册表具有高优先级,因为驱动程序是 数据包。它也是所有传入 HTTP 的服务器范围设置 数据包。

请参考下面的帖子。
Do web.config header size limits override http.sys limits in the registry?
https://serverfault.com/questions/417113/iis-6-header-too-big-how-to-tune-this-iis-setting
How to increase size limit for HTTP header value in request for Azure IIS?

【讨论】:

  • 它可以工作,但仍有 64kb 的限制。有没有办法允许大于 64kb 的标头?
猜你喜欢
  • 1970-01-01
  • 2014-08-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-03-17
  • 1970-01-01
  • 1970-01-01
  • 2020-05-13
相关资源
最近更新 更多