根据您提供的信息,您在nginx配置中设置了以下头部:

  1. add_header Content-Security-Policy "default-src 'self'";
  2. add_header X-Frame-Options "SAMEORIGION";
  3. add_header X-Content-Type-Options "nosniff";

然而,您提到其中的Content-Security-Policy头部似乎无效。

可能的原因是:

  1. 检查您的nginx版本是否支持Content-Security-Policy头部。Content-Security-Policy是在nginx 1.15.2版本及之后引入的。如果您的nginx版本较旧,您需要升级到支持该头部的版本。
  2. 检查其他地方是否覆盖了Content-Security-Policy头部。例如,如果您在nginx配置中的某个地方或其他地方(如应用程序代码)设置了Content-Security-Policy头部,可能会导致冲突和失效。
  3. 检查您的配置文件是否正确。确保在正确的位置和正确的语法下设置了Content-Security-Policy头部。在nginx配置文件中,头部应该位于server块或location块中。

如果您已经确认了上述问题,并且仍然无法使Content-Security-Policy头部生效,请提供更多详细信息,以便能够更好地帮助您解决问题

nginx设置了 add_header Content-Security-Policy default-src self;add_header X-Frame-Options SAMEORIGION;add_header X-Content-Type-Options nosniff;但是add_header Content-Security-Policy default-src self失效了

原文地址: https://www.cveoy.top/t/topic/ii8p 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录