-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Compiling for NGINX without Apache #686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've been working through this for a couple of hours now.. still have not got all the missing libraries but this is where i'm up to (Ubuntu 13 server):
This is where I'm up to, it continues to complain about some curl library. It is a worry that so many libraries need to be installed. Has anyone got past this point? |
This is how I did it in Debian Wheezy cd /opt tar -xvf modsecurity-apache_2.7.7.tar.gz ln -s modsecurity-apache_2.7.7/ mod_security apt-get install build-essential libxml2 libxml2-dev libxml2-utils apache2-threaded-dev libcurl3-dev ~/mod_security# ./configure --enable-standalone-module cd .. wget http://nginx.org/download/nginx-1.4.1.tar.gz ./configure --add-module=../mod_security/nginx/modsecurity root@debian:/opt/nginx# uname -a |
Well, my problem/concern is that if I install 'apache2-threaded-dev' or 'apache2-prefork-dev' via apt, it forces me to also install the Apache binaries with it, even when using '--no-install-recommends'. We already use NGINX as a web server, so it's rather bad if we're forced to install Apache too in order to compile mod_sec. Furthermore, if we configure mod_sec with '--disable-apache2-module', shouldn't it actually stop insisting on APXS, or is that also a requirement to compile the NGINX module? |
Anyone? |
@infinitnet more information on the dependencies are available here: #661. |
@zimmerle Thanks for pointing that out - sorry I missed that existing report. So is anyone working on this already and if so, is there an ETA? It's great that mod_sec for NGINX is finally out of it's alpha/beta phase, but it's dependency on Apache is really annoying with NGINX-only systems. |
You have a valid point, however you need to understand how we were able to port ModSecurity to other platforms. ModSecurity relies heavily on Apache Runtime (APR). It would take a massive recoding to remove those dependencies from the code. What we opted to do was to create a light-weight APR wrapper around ModSecurity to "trick" it into thinking it is always running inside Apache even when it is inside IIS, Nginx, Java, etc... We understand that the dependencies to initially compile it are cumbersome but it is necessary for it to work. We will still investigate ways to make this easier. Hope you understand. |
Wouldn't it be possible to simply include all Apache libs/files needed into the ModSecurity bundle and pull everything that's required for compilation from there instead of from the system environment? |
To come back to this again - for example ngx_pagespeed bundles the APR libraries with PSOL, so it's not required to install the system packages, even though it also relies on APR and this solution works nicely. It would be nice if ModSecurity for NGINX could offer a similar solution. |
It works fine now with a pull from the latest nginx_refacturing branch, but only if you compile ngx_pagespeed before ModSec. |
@infinitnet can you paste an example how do you compiling it with pagespeed? ;) |
@msva Do you mean the configure options or the whole process or anything other specific? |
It would be nice to look on the whole build.log, since I'm unable to build modsecurity without apache installed even from nginx_refactoring branch :( make CFLAGS="-I/usr/include/apr-1 -I../psol/include/third_party/httpd24/src/include -I../psol/include/third_party/httpd24/src/os/unix -I../psol/include/third_party/httpd24/gen/arch/linux/x64/include -I/usr/include/libxml2"
make -f objs/Makefile
make[1]: Entering directory `/var/tmp/portage/www-servers/nginx-1.7.4/work/nginx-1.7.4'
x86_64-pc-linux-gnu-gcc -c -I/usr/include/apr-1 -I../psol/include/third_party/httpd24/src/include -I../psol/include/third_party/httpd24/src/os/unix -I../psol/include/third_party/httpd24/gen/arch/linux/x64/include -I/usr/include/libxml2 -I src/core -I src/event -I src/event/modules -I src/os/unix -I ../ngx_pagespeed-1.8.31.4-beta/psol/include -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/chromium/src -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/google-sparsehash/src -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/google-sparsehash/gen/arch/linux/x64/include -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/protobuf/src -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/re2/src -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/out/Release/obj/gen -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/out/Release/obj/gen/protoc_out/instaweb -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/apr/src/include -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/aprutil/src/include -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/apr/gen/arch/linux/x64/include -I ../ngx_pagespeed-1.8.31.4-beta/psol/include/third_party/aprutil/gen/arch/linux/x64/include -I ../ModSecurity-33b8760e87b7441142a431175d5b459245551314/nginx/modsecurity -I ../ModSecurity-33b8760e87b7441142a431175d5b459245551314/nginx/modsecurity/../../standalone -I ../ModSecurity-33b8760e87b7441142a431175d5b459245551314/nginx/modsecurity/../../apache2 -I objs -I src/http -I src/http/modules -I src/mail \
-o objs/addon/modsecurity/ngx_http_modsecurity.o \
../ModSecurity-33b8760e87b7441142a431175d5b459245551314/nginx/modsecurity/ngx_http_modsecurity.c
In file included from ../ModSecurity-33b8760e87b7441142a431175d5b459245551314/nginx/modsecurity/ngx_http_modsecurity.c:28:0:
../ModSecurity-33b8760e87b7441142a431175d5b459245551314/nginx/modsecurity/../../standalone/api.h:29:28: fatal error: mod_log_config.h: No such file or directory
compilation terminated.
make[1]: *** [objs/addon/modsecurity/ngx_http_modsecurity.o] Error 1
make[1]: Leaving directory `/var/tmp/portage/www-servers/nginx-1.7.4/work/nginx-1.7.4'
make: *** [build] Error 2
|
@infinitnet can you reopen issue, since it is still impossible to build ModSecurity without apache headers and, probably, apsx too? |
thanks ;) |
Already reported on #603. Tracking the progress on: #661. @msva @infinitnet: Can we close this? |
Uhm... As you wish, of course, but it seems, there is no activity in the mentioned issues for a year and two years respectively ;) // and then I don't get the purpose of nginx-refactoring branch. Isn't it for exactly that issue? // Anyway, if you're sure it is enough to have mentioned issues to keep mind on possibility to apacheless install, you can freely close this issue ;) |
By having #661 closed we will be able to have a nginx version free of Apache. Among of other things the nginx_refactoring is indeed built with that in mind. Although, it is not ready yet as you may have notice. Hope to have good news on that front soon. I will let this open. It is now marked as depending on #661. |
@msva I re-opened the issue for you. Are you still unable to compile it without NGINX? Since I know how frustrating it can be, here's a script for you that I just wrote (it's similar to what I use currently) and that should work on Wheezy and Jessie (on Jessie only if you adjust the init file and update-rc.d commands, as that's now systemctl, but I guess that's not the important part about this anyway):
|
@infinitnet yeah I know :( hopefully we can reduce the amount of all unnecessary dependencies soon. Btw, that script seems great. I think it will be very valuable for the community in general. Want to start wiki page for nginx? Maybe place it on Gist? To avoid pollute this issue lets talk about it via email. |
@infinitnet @zimmerle script is very ubuntu-centric (and don't take care on systemd-users, btw, in the time Ubuntu moving on SystemD), but, it probably be nice to have it somewhere just as cheatsheet for somebody ;) |
@msva it's a quick and dirty workaround to at least not have the full Apache packages installed, it is obvious that completely Apache-less isn't possible yet. If that's not good enough for you, I guess you'll have to be patient. @zimmerle the script is quite dirty and rather and example, but sure, if you think it would help people, I can start a wiki page on how to compile ModSecurity with NGINX when I have the time. PS: I see there is a page containing those details already (https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual#Manually_Installing_ModSecurity_Module_on_NGINX), I'll probably just edit that to include Debian system and see if there is a better way for RHEL that required less "garbage". |
I think it is pointless. If you are able to compile modsec with nginx you still have to turn off request processing to let it actually pass anything to the backend servers (read anything over 8k) It is like using antivirus that does not detect any viruses, but uses 25% of your CPU Sent from my iPhone
|
Won't fix in 2.x. libModSecurity no longer depends on Apache or APR. Further information available here - https://github.com/SpiderLabs/ModSecurity-nginx |
Even though I use --disable-apache2-module to compile the standalone module, configure fails with "configure: error: couldn't find APXS". Now to install APXS I have to install the Apache development packages. The problem is, that with Debian based systems, even if you use something like --no-install-recommends with apt, it forces you to install Apache and not only the development libraries. Is there any way around this? I have NGINX running and don't want to bloat my system with Apache. It would cause other issues too, because I'd always have to keep an eye on Apache after OS updates, so it doesn't start automatically and interferes with NGINX.
The text was updated successfully, but these errors were encountered: