首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Azure App Service Linux上设置X-Content-Type-Options?

如何在Azure App Service Linux上设置X-Content-Type-Options?
EN

Stack Overflow用户
提问于 2021-07-24 20:26:07
回答 1查看 210关注 0票数 0

我在Azure app Service Linux上部署了一个Angular2 web应用。我运行OWASP ZAP攻击我的网站,它警告X-Content-Type-Options头文件丢失。我在etc/中查找httpd文件以设置X-Content-Type-Options = 'nosniff‘,但我找不到它。我假设web应用程序在Apache上运行。

参考资料:

The Anti-MIME-Sniffing header X-Content-Type-Options was not set to 'nosniff'. This allows older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body, potentially causing the response body to be interpreted and displayed as a content type other than the declared content type. Current (early 2014) and legacy versions of Firefox will use the declared content type (if one is set), rather than performing MIME-sniffing.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-07-25 15:05:18

我们通过将两个文件ecosystem.config.jsserve.json作为我们部署的工件的一部分来解决这个问题。

ecosystem.config.js

代码语言:javascript
复制
// https://burkeknowswords.com/this-is-how-to-easily-deploy-a-static-site-to-azure-96c77f0301ff
// Use PM2 to serve files on Linux App Service
module.exports = {
    apps: [
        {
            script: "npx serve -s"
        }
    ]
};

serve.json

代码语言:javascript
复制
{
    "headers": [
        {
            "source" : "**",
            "headers" : [
                {
                    "key" : "X-Content-Type-Options",
                    "value" : "nosniff"
                },
                // more headers
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68509954

复制
相关文章

相似问题

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