【问题标题】:NGINX Parsing and failing Content Security Policy on reloadNGINX 重新加载时解析和失败的内容安全策略
【发布时间】:2017-07-21 16:17:58
【问题描述】:

这是一个服务器端 CSP 问题。在 NGINX 中,我在重新加载配置时遇到了许多问题,因为我的内容安全策略标头给我带来了困难。

[root@www1 ~]# service nginx reload
nginx: [emerg] unknown directive "script-src" in /etc/nginx/conf.d/ssl.conf:15
nginx: configuration file /etc/nginx/nginx.conf test failed

这个策略我已经重写了大概8次了,但是NGINX不会接受它。 NGINX版本为nginx/1.10.2,CentOS 6.8,内核2.6.32-642.13.1.el6.x86_64

server {

[...] //Stuff

add_header Content-Security-Policy:"default-src 'self';script-src 'self' 'unsafe-inline' https://bam.nr-data.net https://js-agent.newrelic.com https://cdn.mxpnl.com https://ajax.cloudflare.com https://*.redacted.co;style-src 'self' https://*.redacted.co;img-src *;font-src 'self' https://*.redacted.co https://cloud.typography.com; object-src 'none';frame-src 'none';upgrade-insecure-requests;";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; ";
add_header X-Frame-Options "DENY";
add_header X-XSS-Protection "1; mode=block";

[...] //Stuff

}

我有什么明显的遗漏吗?

【问题讨论】:

    标签: nginx centos6 content-security-policy


    【解决方案1】:

    看起来我在不应该的地方添加了一个冒号。删除,NGINX 突然高兴起来。

    add_header Content-Security-Policy: 应该是add_header Content-Security-Policy

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-15
      相关资源
      最近更新 更多