Error when compiling Openresty with mod_security

493 views
Skip to first unread message

Vizualt

unread,
Feb 22, 2015, 1:13:22 AM2/22/15
to openre...@googlegroups.com
Hello,

Please help, i have error like this when compiling lua with mod_security:

/usr/bin/ld: cannot find -llua
collect2: ld returned 1 exit status
gmake[2]: *** [objs/nginx] Error 1
gmake[2]: Leaving directory `/usr/local/src/ngx_openresty-1.7.7.2/build/nginx-1.7.7'
gmake[1]: *** [build] Error 2
gmake[1]: Leaving directory `/usr/local/src/ngx_openresty-1.7.7.2/build/nginx-1.7.7'
gmake: *** [all] Error 2

Thank you so much.

Yichun Zhang (agentzh)

unread,
Feb 22, 2015, 1:18:08 PM2/22/15
to openresty-en
Hello!

On Sat, Feb 21, 2015 at 10:13 PM, Vizualt wrote:
> Please help, i have error like this when compiling lua with mod_security:
>
> /usr/bin/ld: cannot find -llua
> collect2: ld returned 1 exit status

Seems like the modsecurity module for nginx tries to link against the
standard Lua interpreter while OpenResty/ngx_lua tries to link against
its bundled version of LuaJIT by default. They won't work together.

A simple workaround is to remove the "-llua" or "-llua5.1" linker
option from modsecurity's "config" file in its source tree (should be
the file nginx/modsecurity/config or something like that). You can try
that on your side.

Regards,
-agentzh

Vizualt

unread,
Feb 22, 2015, 11:24:39 PM2/22/15
to openre...@googlegroups.com
Hello,

Thank you for your instructions, agentzh. 
I've done it, by removing -llua on the file "config" like this:

Before:
====================================
CORE_LIBS="$CORE_LIBS \
     -lapr-1 \
     -L/usr/lib64 -laprutil-1 \
    -I/usr/local/apache/include \
     \
    -L/opt/xml2/lib -lxml2 -lz -lm -ldl \
    -llua \  <<<<<<<<<<<<<<<<<<<<------------------------- I've deleted this
    -lpcre \
    -L/usr/local/apache/lib  -lm \
     \
    "
================================


After:
==================================
CORE_LIBS="$CORE_LIBS \
     -lapr-1 \
     -L/usr/lib64 -laprutil-1 \
    -I/usr/local/apache/include \
     \
    -L/opt/xml2/lib -lxml2 -lz -lm -ldl \
    -lpcre \
    -L/usr/local/apache/lib  -lm \
     \
    "
===================================


And i tried to re-compile openresty with mod_security, but I got a new error message like this:

=================
/usr/local/src/modsecurity-2.8.0/nginx/modsecurity/../../standalone/.libs/standalone.a(standalone_la-msc_crypt.o): In function `inject_hashed_response_body':
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1079: undefined reference to `xmlOutputBufferGetSize'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1110: undefined reference to `xmlOutputBufferGetSize'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1122: undefined reference to `xmlOutputBufferGetSize'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1132: undefined reference to `xmlOutputBufferGetContent'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1081: undefined reference to `xmlOutputBufferGetSize'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1093: undefined reference to `xmlOutputBufferGetSize'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1103: undefined reference to `xmlOutputBufferGetContent'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1106: undefined reference to `xmlOutputBufferGetSize'
/usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1135: undefined reference to `xmlOutputBufferGetSize'
collect2: ld returned 1 exit status
gmake[2]: *** [objs/nginx] Error 1
gmake[2]: Leaving directory `/usr/local/src/ngx_openresty-1.7.7.2/build/nginx-1.7.7'
gmake[1]: *** [build] Error 2
gmake[1]: Leaving directory `/usr/local/src/ngx_openresty-1.7.7.2/build/nginx-1.7.7'
gmake: *** [all] Error 2
=================================

I hope you can give me an enlightenment. 

Thank you very much.

Lord Nynex

unread,
Feb 23, 2015, 12:07:20 AM2/23/15
to openre...@googlegroups.com
You're trying to compile an apache module into nginx?

--
You received this message because you are subscribed to the Google Groups "openresty-en" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openresty-en...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Vizualt

unread,
Feb 23, 2015, 12:19:04 AM2/23/15
to openre...@googlegroups.com
Hello Lord Nyney,

I tried to follow the tutorial below https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#Installation_for_NGINX

And I download files mod_security at the following url https://www.modsecurity.org/tarball/2.8.0/modsecurity-2.8.0.tar.gz
The contents of the file "config" as I mentioned above. 

Directory sructure like this:

root@myserv [/usr/local/src/modsecurity-2.8.0/nginx/modsecurity]# ll
total 84
drwx------ 2  119  128  4096 Feb 22 07:41 ./
drwx------ 3  119  128  4096 Apr 15  2014 ../
-rw------- 1  119  128  6410 Apr 15  2014 apr_bucket_nginx.c
-rw------- 1  119  128   706 Apr 15  2014 apr_bucket_nginx.h
-rw-r--r-- 1 root root  1147 Feb 23 07:03 config
-rw------- 1  119  128  1004 Apr 15  2014 config.in
-rw------- 1  119  128 41989 Apr 15  2014 ngx_http_modsecurity.c
-rw------- 1  119  128  5958 Apr 15  2014 ngx_pool_context.c
-rw------- 1  119  128   446 Apr 15  2014 ngx_pool_context.h


When I try to compile with openresty unsuccessful. Is there something wrong?

I am very grateful if you could give me another clue.

Thank you very much.

Yichun Zhang (agentzh)

unread,
Feb 23, 2015, 2:04:12 AM2/23/15
to openresty-en
Hello!

On Sun, Feb 22, 2015 at 8:24 PM, Vizualt wrote:
> /usr/local/src/modsecurity-2.8.0/nginx/modsecurity/../../standalone/.libs/standalone.a(standalone_la-msc_crypt.o):
> In function `inject_hashed_response_body':
> /usr/local/src/modsecurity-2.8.0/standalone/../apache2/msc_crypt.c:1079:
> undefined reference to `xmlOutputBufferGetSize'

Seems like an issue with your libxml installation (or path). A quick
google search reveals that people may get this with the standard nginx
core (not OpenResty) as well:

https://github.com/SpiderLabs/ModSecurity/issues/145

So better check out this ticket and/or contact the maintainers of the
modsecurity module instead :)

Regards,
-agentzh

Vizualt

unread,
Feb 23, 2015, 2:51:43 AM2/23/15
to openre...@googlegroups.com
Hello agentzh,

Okey, thank you for your information.
I will try to solve this issue. I hope i can :D

Thank you so much.

Moni Chen

unread,
Jun 4, 2016, 1:00:59 AM6/4/16
to openresty-en
This will help you fix lua problem:
yum -y install lua-devel lua
Reply all
Reply to author
Forward
0 new messages