因此,我已经在其他答案和其他站点中看到了此解决方案(http://www.hanselman.com/blog/HowToEnableHTTPStrictTransportSecurityHSTSInIIS7.aspx),但我不知道如何添加HSTS header 。我认为这与它有很大关系:

<match serverVariable="RESPONSE_Strict_Transport_Security" pattern=".*" />

有人可以解释“RESPONSE_Strict_Transport_Security”的来源吗?

完整代码:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <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>
            </rules>
            <outboundRules>
                <rule name="Add Strict-Transport-Security when HTTPS" enabled="true">
                    <match serverVariable="RESPONSE_Strict_Transport_Security"
                        pattern=".*" />
                    <conditions>
                        <add input="{HTTPS}" pattern="on" ignoreCase="true" />
                    </conditions>
                    <action type="Rewrite" value="max-age=31536000" />
                </rule>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

最佳答案

我想我找到了。从"URL Rewrite Module 2.0 Configuration Reference":



然后在文档中:



因此,该示例中的代码表示:“如果Strict-Transport-Security响应头具有任何值(.*),包括未定义,则将该值重写为max-age=31536000(如果满足条件)。

关于c# - "RESPONSE_Strict_Transport_Security"服务器变量,用于在IIS中强制使用SSL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/42306886/

10-10 10:48