我在 Linux 6.6 上通过 Apache 2.4.18 配置了 SVN。接下来我必须为我的 svn url 禁用跨框架脚本。SVN url 就像https://servername/svn/projectA。我已经编译了 mod_security2.so 并复制到 /modules 目录,然后在 virtualHost 中加载了以下行。
LoadFile /usr/lib64/libxml2.so
LoadFile /usr/lib64/liblua-5.1.so
LoadModule security2_module modules/mod_security2.so
httpd-vhosts.conf
<VirtualHost *:80>
ServerAdmin email@domain.com
DocumentRoot "/var/local/apache/httpd2.4.18/htdocs"
ServerName servername.fqdn.com
# For http to https redirect
Redirect / https://servername
TraceEnable off
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK)
RewriteRule .* - [F]
SecRuleEngine On
#SecFilterEngine On
#SecFilterForceByteRange 32 126
#SecFilterScanPOST On
#SecFilter "<( |\n)*script"
SecRequestBodyAccess On
SecResponseBodyAccess On
ErrorLog "logs/error_log"
CustomLog "logs/access_log" common
</VirtualHost>
Apache 不支持的规则是
SecFilterEngine SecFilterForceByteRange SecFilterScanPOST SecFilter Blockquote
而不是 SecFilterEngine,它采用 SecRuleEngine。但我不知道其他规则的替代规则。我正在使用 modsecurity-2.9.0 源代码编译。我看到的错误如下。[root@server extra]# /var/local/apache/httpd2.4.18/bin/apachectl configtest AH00526: /var/local/apache/httpd2.4.18/conf/extra/httpd-vhosts.conf 第 45 行的语法错误:无效的命令“SecFilterForceByteRange”,可能拼写错误或由服务器配置中未包含的模块定义。任何人都知道 SecFilterForceByteRange、SecFilterScanPOST 和 SecFilter 的 mod_security2 支持模块。我还阅读了有关 mod_security 的文档,但无法弄清楚并解决问题。我按照下面的网址。
http://www.unixpearls.com/how-to-block-xss-vulnerability-cross-site-scripting-in-apache-2-2-x/
[编辑] 它通过添加标题响应来解决。