ningx配置ModSecurity重启出现兼容性问题:ModSecurity: Loaded PCRE do not match with compiled!的解决方法

nginx开启错误日志,然后重启nginx,出现如下信息:

2016/12/03 09:40:38 [notice] 18858#0: ModSecurity for nginx (STABLE)/2.9.1 (http://www.modsecurity.org/) configured.
2016/12/03 09:40:38 [notice] 18858#0: ModSecurity: APR compiled version="1.4.8"; loaded version="1.4.8"
2016/12/03 09:40:38 [notice] 18858#0: ModSecurity: PCRE compiled version="8.39 "; loaded version="8.32 2012-11-30"
2016/12/03 09:40:38 [warn] 18858#0: ModSecurity: Loaded PCRE do not match with compiled!
2016/12/03 09:40:38 [notice] 18858#0: ModSecurity: LIBXML compiled version="2.9.1"
2016/12/03 09:40:38 [notice] 18858#0: ModSecurity: StatusEngine call: "2.9.1,nginx,1.4.8/1.4.8,8.39/8.32 2012-11-30,(null),2.9.1,1041d4bc04a4b99eb3aab2c7d5ad7bbeb72f7b5b"
2016/12/03 09:40:38 [notice] 18858#0: ModSecurity: StatusEngine call successfully sent. For more information visit: http://status.modsecurity.org/

注意红色字体部分就是兼容性的错误提示:

要求PCRE的软件版本是8.39,系统加载的是软件版本是8.32,所以更新PCRE软件版本到8.39即可解决这个问题。

那么问题来了

通过/usr/local/nginx/sbin/nginx -V 查看nginx的编译参数,PCRE的软件版本是8.39

nginx version: nginx/1.10.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)
built with OpenSSL 1.0.2j  26 Sep 2016
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.2j --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.39 --add-module=/usr/local/src/modsecurity-2.9.1/nginx/modsecurity

也就是说在安装nginx的时候已经安装pcre8.39软件版本了,但是看系统上的pcre软件版本却不是8.39,还是系统本身自带的软件版本8.32,具体查看如下:

# rpm -qa | grep pcre
pcre-devel-8.32-15.el7_2.1.x86_64
pcre-8.32-15.el7_2.1.x86_64

# pcre-config --version
8.32

解决方法:

1、查看系统安装的pcre软件

#rpm -qa | grep pcre
pcre-devel-8.32-15.el7_2.1.x86_64
pcre-8.32-15.el7_2.1.x86_64

2、忽略软件依赖性卸载pcre软件
#rpm -e --nodeps pcre-8.32-15.el7_2.1.x86_64
#rpm -e --nodeps pcre-devel-8.32-15.el7_2.1.x86_64

3、下载pcre.39源码进行安装

wget http://ftp.exim.llorien.org/pcre/pcre-8.39.tar.gz

tar zxvf pcre-8.39.tar.gz

cd pcre-8.39

./configure --enable-utf8(后面会说到这个)

make && make install

然后重启nginx,则不会出现ModSecurity兼容性显示,nginx错误日志如下显示:

2016/12/03 10:09:50 [notice] 28116#0: ModSecurity for nginx (STABLE)/2.9.1 (http://www.modsecurity.org/) configured.
2016/12/03 10:09:50 [notice] 28116#0: ModSecurity: APR compiled version="1.4.8"; loaded version="1.4.8"
2016/12/03 10:09:50 [notice] 28116#0: ModSecurity: PCRE compiled version="8.39 "; loaded version="8.39 2016-06-14"
2016/12/03 10:09:50 [notice] 28116#0: ModSecurity: LIBXML compiled version="2.9.1"
2016/12/03 10:09:50 [notice] 28116#0: ModSecurity: StatusEngine call: "2.9.1,nginx,1.4.8/1.4.8,8.39/8.39 2016-06-14,(null),2.9.1,1041d4bc04a4b99eb3aab2c7d5ad7bbeb72f7b5b"
2016/12/03 10:09:50 [notice] 28116#0: ModSecurity: StatusEngine call successfully sent. For more information visit: http://status.modsecurity.org/

查看pcre软件版本:

#rpm -qa | grep pcre (不是通过rpm方式安装的,所以这个命令查看不到)
#pcre-config --version (查看到软件版本是8.39)
8.39

#pcretest -C (换个命令查看还是8.39)
PCRE version 8.39 2016-06-14
Compiled with
  8-bit support
  No UTF-8 support (不支持utf-8)
  No Unicode properties support
  No just-in-time compiler support
  Newline sequence is LF
  \R matches all Unicode newlines
  Internal link size = 2
  POSIX malloc threshold = 10
  Parentheses nest limit = 250
  Default match limit = 10000000
  Default recursion depth limit = 10000000
  Match recursion uses stack

注意:看到pcre不支持utf-8,需要在安装编译pcre是加上参数,--enable-utf8,最终如下:./configure --enable-utf8

时间: 2024-07-29 18:06:24

ningx配置ModSecurity重启出现兼容性问题:ModSecurity: Loaded PCRE do not match with compiled!的解决方法的相关文章

配置server.xml后,启动tomcat 失败(Unable to start cluster)及解决方法

在配置负载均衡环境过程中修改server.xml  后重启tomcat报错,报错信息如下 [[email protected] bin]# ./catalina.sh runUsing CATALINA_BASE: /usr/local/TC6_AUsing CATALINA_HOME: /usr/local/TC6_AUsing CATALINA_TMPDIR: /usr/local/TC6_A/tempUsing JRE_HOME: /usr/java/jdk1.6.0_45Using CL

[转]resolv.conf 配置信息重启后丢失解决方法

我要配置DNS,修改/etc/resolv.conf,修改后重启服务 service network restart ,修改/etc/resolv.conf的信息丢失,请大家看看. 修改前的配置# No nameservers found; try putting DNS servers into your# ifcfg files in /etc/sysconfig/network-scripts like so:## DNS1=xxx.xxx.xxx.xxx# DNS2=xxx.xxx.xx

云主机配置Docker Bridge,在重新颠倒配置,重启网卡,导致物理网卡不正常工作

1,物理机配置,eth0,eth1 配置bonding,bonding 作为bridge 物理网卡,在生成bond0 作为物理机管理口 2,虚拟机配置,eth1 作为bridge 虚拟网卡br500, eth0 配置正常网卡IP 3, 因eth0 为WEB 段, eth1 为DB 段,需颠倒配置,重启网卡,出现以下问题 4,相关错误日志: an  3 14:46:41 localhost kernel: device vnet0 entered promiscuous mode Jan  3 1

网御星云WAF的配置页面与浏览器兼容性问题

有一旧的WAF设备要用起来,同事已经提前测试出了管理口IP和账号密码,机器上架后登录控制台,新建"真实服务器"填了IP后点击"提交"按钮没有任何反应.试了很多次换不同IP都没反应,而且"应用防护"几个选项都显示空白,本以为是该设备恢复了出厂设置,加之会不会是授权过期导致的. 再请同事通过远程连过来检查,测试一番也是同样情况.只是通过其它操作设置我看到了以前配置的服务器IP,虽然也是点击"提交"没有反应,但是确实设置的IP在列表

ldap安装配置过程中遇到的错误,以及解决方法

错误1: [[email protected] openldap]# ldapsearch -LLL-W -x -H ldap://etiantian.org -D "cn=admin,dc=etiantian,dc=org" -b"dc=etiantian,dc=org" "(uid=*)" Enter LDAP Password: ldap_bind: Invalid credentials (49) 错误描述: 搜选的时候,提示ldap_b

resolv.conf 配置信息丢失解决方法

resolv.conf 配置信息丢失解决方法 配置DNS,修改/etc/resolv.conf,修改后重启服务 service network restart ,修改/etc/resolv.conf的信息丢失,请大家看看. [code]修改前的配置 # No nameservers found; try putting DNS servers into your # ifcfg files in /etc/sysconfig/network-scripts like so: # # DNS1=x

Win10首次启动出现计算机意外地重启或遇到错误的解决方法

Win10系统 安装完后首次开机时系统弹出窗口,提示:计算机意外重新启动或遇到错误,导致系统安装无法继续.这是怎么回事,下面让小编来讲解这个问题的解决方法吧. 故障分析: 首次启动Win10系统时提示:计算机意外地重新启动或遇到错误.Windows 安装无法继续.若要安装Windows,请单击"确定"重新启动计算机,然后重新启动安装" 解决方法: 1.按下shift+f10 会打开命令窗口,进入到C:/windows/system32/oobe文件夹,输入msoobe回车然后

CentOS网络配置后无法访问外网的解决方法

CentOS网络配置后无法访问外网的解决方法 关于CentOS网络的具体配置项,可以参考Mitchell博客之前的那篇文章. 现象: ping内网正常ping外网IP,域名均无法正常,返回错误:connect: Network is unreachable 后面在无意中看到Linux网络配置有添加网关的命令: 复制代码 代码如下: route add default gw 192.168.128.2 dev eth0 按上面操作,添加了默认的网关之后.再次访问外网一切正常. 有这个现象来看,应该

Exchange 2016 &XP&outlook 2010 sp2无法配置解决方法

环境:Server :Windows Server 2016 + Exchange Server 2016 CU4客户端:Windows XP sp3 + outlook 2010 sp2 以上环境无法配置outlook,会一直提示输入密码,在win7下正常.解决方法如下:顺利列出其他环境的解决方法: Exchange 2007/2010 Set-OutlookAnywhere -Identity 'SERVER\Rpc (Default Web Site)' -SSLOffloading $t