【发布时间】: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