我正在尝试向我的 Web 应用程序添加 HSTS 和 X-XSS。我一直在使用这个进行测试: https://securityheaders.io
我一直使用此链接作为起始参考:
我在 /site/wwwroot 中添加了 web.config 文件,我停止并启动了我的 web 应用程序,但它看起来没有效果(我认为 web.config 不是必需的)
我有 Linux 网络应用程序(Slack:NodeJS)
我将如何做到这一点?
谢谢!
答案 0 :(得分:1)
您可以在代码中更改 Content-Security-Policy
。这是解决您问题的更好方法。
相关博客。 How To Secure Node.js Applications with a Content Security Policy
我发现在azure linux中,并不能直接知道linux服务器使用的是哪个webserver,所以没有尝试下面的方法。如果您有兴趣,可以提出支持寻求帮助,让 Microsoft 工程师帮助您。
由于您使用的是 linux 平台,因此您需要确定您在网络应用中使用的网络服务器。
如果使用apache,可以添加.htaccess文件来解决问题。
Implement Content Security Policy using local htaccess file (Apache)
如果是 nginx,你可以添加 yourcustom.conf 文件来做到这一点。