0
我有一個ASP.NET Webforms應用程序,它使用的是NWebsec。它按預期工作,但我試圖從一開始就強制使用HTTPS,而不是在使用HSTS進行初始請求之後。當我添加URL重寫時,它會進入重定向循環。刪除NWebsec和URL重寫工作正常。 NWebsec可以在任何情況下工作,但如果加載HTTP則不會重寫,因此不會強制使用HTTPS。 upgrade-insecure-requests
不適用於它自己。NWebsec和URL重寫衝突
URL重寫規則
<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配置
<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>