2017-02-17 57 views
4

因此,我在其他答案和其他站点中看到了此解决方案(http://www.hanselman.com/blog/HowToEnableHTTPStrictTransportSecurityHSTSInIIS7.aspx),但我不明白如何添加HSTS标头。我认为它有很多与此有关:“RESPONSE_Strict_Transport_Security”服务器变量用于在IIS中强制使用SSL

<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> 

回答

0

我不能指向您在这方面的确切来源,但我可以从实验告诉你,“RESPONSE_Strict_Transport_Security”增加了“严格,运输安全头到响应与“RESPONSE_Expect_Staple”添加“期望主页”标题的方式完全相同。

以下两个链接有一些提示,我们可以期待上述行为,但我从来没有找到有关这种方式的准确文档。

https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/modifying-http-response-headers

Add custom header based on file type