【发布时间】:2021-09-01 13:51:25
【问题描述】:
我们在产品中使用 Apache HTTPS 服务器。作为 XSS(跨站点脚本)的修复,我尝试在 httpd.conf 文件中添加 Content-Security-Policy。但它不起作用,并且在此更改后服务器无法启动。
目前我收到了来自服务器的回复:
curl -k -I https://IP:Port
HTTP/1.1 200 OK
Date: Wed, 16 Jun 2021 16:53:12 GMT
Set-Cookie: JSESSIONID=xxxxxx; Path=/; Secure
X-Frame-Options: SAMEORIGIN
Cache-Control: no-cache
Content-Length: 1234
Content-Type: text/html;charset=UTF-8
作为在 HTTP 响应中包含 CSP 的修复,我更新了 httpd.conf
Content-Security-Policy: script-src 'self'
使用“httpd -t”验证语法时出现以下错误:
Invalid command 'Content-Security-Policy:', perhaps misspelled or defined by a module not included in the server configu
ration
还尝试了这些更改:
<IfModule mod_headers.c>
Header set X-XSS-Protection"1; mode=block"
Header set Content-Security-Policy="default-src 'self';"
</IfModule>
现在语法错误是:
Header requires three arguments
我在配置或其他方面有什么遗漏吗?
【问题讨论】:
-
我试过用 = 登录
Header set X-XSS-Protection="1; mode=block",但还是同样的错误。 -
其实试试把
Header set Content-Security-Policy="default-src 'self';"中的等号去掉。
标签: xss httpd.conf content-security-policy