首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >NWebsec和URL重写冲突

NWebsec和URL重写冲突
EN

Stack Overflow用户
提问于 2016-08-05 00:42:33
回答 1查看 243关注 0票数 0

我有一个ASP.NET Webforms应用程序,它正在使用NWebsec。它按预期工作,但我试图从一开始就强制HTTPS,而不是在使用HSTS进行初始请求之后。当我添加URL重写时,它会在一个重定向循环中得到。删除NWebsec和URL重写很好。NWebsec在这两种情况下都可以工作,但是如果没有重写,如果它们加载了HTTP,它就不会强制HTTPS。upgrade-insecure-requests本身不起作用。

URL重写规则

代码语言:javascript
复制
<rules>
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
        <match url="(.*)" />
        <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
        </conditions>
        <action type="Redirect" url="https://{HTTP_HOST}/{R:1}"
redirectType="Permanent" />
</rule>

NWebsec Config

代码语言:javascript
复制
<nwebsec>
  <httpHeaderSecurityModule xmlns="http://nwebsec.com/HttpHeaderSecurityModuleConfig.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="NWebsecConfig/HttpHeaderSecurityModuleConfig.xsd">
    <redirectValidation enabled="true" />
      <setNoCacheHttpHeaders enabled="true" />
      <x-Robots-Tag enabled="false" noIndex="false" noFollow="false" noArchive="false" noOdp="false" noSnippet="false" noImageIndex="false" noTranslate="false" />
      <securityHttpHeaders>
        <x-Frame-Options policy="Deny" />
        <strict-Transport-Security max-age="60" includeSubdomains="true" httpsOnly="true" preload="false" />
        <x-Content-Type-Options enabled="true" />
        <x-Download-Options enabled="false" />
        <x-XSS-Protection policy="Disabled" blockMode="true" />
        <content-Security-Policy enabled="true">
          <upgrade-insecure-requests enabled="true"  />
        </content-Security-Policy>
      </securityHttpHeaders>
    </httpHeaderSecurityModule>
</nwebsec>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-08-05 02:10:22

发现了问题,PEBKAC。应该更好地阅读文档

代码语言:javascript
复制
<redirectValidation enabled="true">
    <allowSameHostRedirectsToHttps enabled="true" />
</redirectValidation>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38779498

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档