1{ stdenv, lib, fetchurl, pkgconfig
2, curl, apacheHttpd, pcre, apr, aprutil, libxml2
3, luaSupport ? false, lua5
4}:
5
6with lib;
7
8let luaValue = if luaSupport then lua5 else "no";
9 optional = stdenv.lib.optional;
10in
11
12stdenv.mkDerivation rec {
13 name = "modsecurity-${version}";
14 version = "2.9.2";
15
16 src = fetchurl {
17 url = "https://www.modsecurity.org/tarball/${version}/${name}.tar.gz";
18 sha256 = "41a8f73476ec891f3a9e8736b98b64ea5c2105f1ce15ea57a1f05b4bf2ffaeb5";
19 };
20
21 nativeBuildInputs = [ pkgconfig ];
22 buildInputs = [ curl apacheHttpd pcre apr aprutil libxml2 ] ++
23 optional luaSupport lua5;
24
25 configureFlags = ''
26 --enable-standalone-module
27 --enable-static
28 --with-curl=${curl.dev}
29 --with-apxs=${apacheHttpd.dev}/bin/apxs
30 --with-pcre=${pcre.dev}
31 --with-apr=${apr.dev}
32 --with-apu=${aprutil.dev}/bin/apu-1-config
33 --with-libxml=${libxml2.dev}
34 --with-lua=${luaValue}
35 '';
36
37 outputs = ["out" "nginx"];
38 # by default modsecurity's install script copies compiled output to httpd's modules folder
39 # this patch removes those lines
40 patches = [ ./Makefile.in.patch ];
41
42 postInstall = ''
43 mkdir -p $nginx
44 cp -R * $nginx
45 '';
46
47 meta = {
48 description = "Open source, cross-platform web application firewall (WAF)";
49 license = licenses.asl20;
50 homepage = https://www.modsecurity.org/;
51 maintainers = with maintainers; [offline];
52 platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
53 };
54}