如何将安全标头添加到容器的Azure App服务中

时间:2019-09-16 19:54:43

标签: http-headers azure-web-app-service docker-container hsts

在将其作为docker容器(linux)部署时,如何将自定义http安全标头(如HSTS)添加到Azure应用服务方面的成功有限。我不确定这是否可以直接在应用程序服务上实现,或者是否需要诸如应用程序网关之类的东西。

如果使用kubernetes或swarm,我可以在反向代理入口上执行此操作,但是如何在应用程序服务上完成此操作?

1 个答案:

答案 0 :(得分:0)

2个解决方案:

  1. 转到Azure门户,然后在:
  

您的功能应用程序->平台功能->自定义域并设置HTTPS   仅达到所需值(开)。

  1. 将此添加到web.config
<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>