HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
owasp-modsecurity
ModSecurity
C++2021–2024
owasp-modsecurity / ModSecurity

ModSecurity

ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx. It has a robust event-based programming language which provides protection from a range of attacks against web applications and allows for HTTP traffic monitoring, logging and real-time analysis.

4Distinct people
5Mentions
0Explicit recommenders
9.9KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx. It has a robust event-based programming language which provides protection from a range of attacks against web applications and allows for HTTP traffic monitoring, logging and real-time analysis.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 1:49:46 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year5 dated mentions

Observed mentions: 2021-04-07 03:29:32 UTC to 2024-08-15 06:14:10 UTC.

0122021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20212022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20222023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2024

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC101
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC101
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC202
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101

What Hacker News says

5 sources
> that's irrelevant to the core developers That's relevant to me! If I want Apache to act as an OpenID connect relying party, for example, I can just use mod_auth_openidc https://github.com/OpenIDC/mod_auth_openidc installing which is pretty much trivial and requires little work on my part: sudo apt install libapache2-mod-auth-openidc If I want something similar for Nginx, I can take a look here https://openid.net/developers/certified-openid-connect-imple... and realize that I'll need to use OpenResty with LuaRocks, which does add a bit more complexity: https://github.com/zmartzone/lua-resty-openidc luarocks install lua-resty-openidc If I want a basic WAF with something that runs ModSecurity rules, on Apache I can just do: libapache2-mod-security2 and can use the OWASP CRS with no issues: https://owasp.org/www-project-modsecurit
Read the rest
y-core-rule-set/ With Nginx that is no longer properly supported and needed their Plus version anyways: https://docs.nginx.com/nginx-waf/admin-guide/nginx-plus-mods... sudo apt-get install nginx-plus-module-modsecurity If I want to do that myself with the regular Nginx, I suddenly have to compile a bunch of stuff myself, which becomes far less pleasant and a bit more long winded: https://www.linode.com/docs/guides/securing-nginx-with-modse... sudo apt-get install bison build-essential ca-certificates curl dh-autoreconf doxygen \ flex gawk git iputils-ping libcurl4-gnutls-dev libexpat1-dev libgeoip-dev liblmdb-dev \ libpcre3-dev libpcre++-dev libssl-dev libtool libxml2 libxml2-dev libyajl-dev locales \ lua5.3-dev pkg-config wget zlib1g-dev zlibc libxslt libgd-dev sudo apt install git cd /opt && sudo git clone https://github.com/SpiderLabs/ModSecurity cd ModSecurity sudo git submodule init sudo git submodule update sudo ./build.sh sudo ./configure sudo make sudo make install cd /opt && sudo git clone --depth 1 https://github.com/SpiderLabs/ModSecurity-nginx.git cd /opt && sudo wget http://nginx.org/download/nginx-1.14.0.tar.gz sudo tar -xvzmf nginx-1.14.0.tar.gz cd nginx-1.14.0 sudo ./configure --add-dynamic-module=../ModSecurity-nginx <Configure Arguments> sudo make modules sudo mkdir /etc/nginx/modules sudo cp objs/ngx_http_modsecurity_module.so /etc/nginx/modules (old versions in the example, but same principle) At that point I might as well look in the direction of OWASP Coraza: https://coraza.io/ When it comes to ACME and Let's Encrypt, I can use mod_md out of the box with Apache: https://httpd.apache.org/docs/2.4/mod/mod_md.html It's experimental but works nicely in my experience, whereas with Nginx, I have to go with Certbot separately: https://certbot.eff.org/ If I want everything in a single package, I can just use Caddy instead (which is a lovely web server). And that's before I get into weird Nginx behavior when I try to use it with containers, where the whole web server crashes, just because it cannot find the DNS record for a container that hasn't been created yet, along the lines of: nginx: [emerg] host not found in upstream "my-app" where trying to use the suggested fix leads to: nginx: [emerg] "proxy_redirect default" cannot be used with "proxy_pass" directive with variables and using other values often breaks app redirects. Due to these experiences, I'll absolutely say that you can do more with Apache, in ways that will be less of a pain, except for the whole "getting your entire web server hacked" or "brought down by any sizeable amount of traffic" bit. Nginx is really good for hosting static content or acting as a basic reverse proxy, but will be harder to get various bits of the greater ecosystem into it, as opposed to how Apache works. Then again, I fully acknowledge that someone will come along and say "ModSecurity isn't very useful, you should just put your site behind Cloudflare if you need a WAF." or maybe even "Don't handle OpenID Connect in your ingress, even if that means that in the case of 5 APIs you'll need OIDC libraries and configuration for each of them, which will look quite different in various languages." but that doesn't change the fact that some things are just more doable in one option instead of another. OpenResty or Caddy increasingly feel like better choices for a lot of stuff, but not bare Nginx. Use Nginx when you want to handle simple use cases (reverse proxy, serving static files) with good performance, security and a sane configuration format.
In Confusion Attacks: Exploiting Hidden Semantic Ambiguity in Apache HTTP Server
> ModSecurity for WAF: https://github.com/SpiderLabs/ModSecurity This might be of interest to some: https://www.modsecurity.org/ > Trustwave is announcing the End-of-Life (EOL) of our support for ModSecurity effective July 1, 2024. We will then hand over the maintenance of ModSecurity code back to the open-source community. Probably not too big of a deal, though. Also, this might be useful: https://owasp.org/www-project-modsecurity-core-rule-set/ Though there has been some critique of ModSecurity and that ruleset in the past, as something dated and with false positives. Anyone have any good alternatives?
In Ask HN: What's a good open-source alternative to Cloudflare?
Building your own DDOS protection and CDN will involve a lot of devops bandwidth in ensuring both low latency and high availability. You may need to negotiate good rates with your ISP/VPS/Cloud for network bandwidth. It will also involve keeping in sync with security fixes and the state of the art in terms of bot protection, etc. If this use case is not a core part of your business, it will be better to bite the bullet and go ahead with a 3rd party solution like Cloudflare / AWS Cloudfront + WAF + Route 53 / Google Cloud Armor / Fastly Openresty with a few Nginx modules and Lua scripts can go a long way for many use-cases mentioned: - ModSecurity for WAF: https://github.com/SpiderLabs/ModSecurity - L7 Rate limiting: https://github.com/openresty/lua-resty-limit-traffic - Cache: https://github.com/ledgetech/ledge . Or use varnish which give
Read the rest
s you VCL for high configurability - Load balancing: https://github.com/openresty/lua-resty-balancer - CDN: https://github.com/taythebot/lightpath . This project seems to be a WIP which you can use as a starting point for your needs. You will also need to find good enough "edge" locations for your CDN. Similarly, HAProxy does a lot of stuff with the correct config and is also extensible using Lua: - Some basic DOS protection: https://www.sysbee.net/blog/haproxy-sysadmins-swiss-army-kni... - L7 DDoS protection: https://github.com/mora9715/haproxy_ddos_protector You can run your own authoritative DNS server using either djbdns or nsd. Or use AWS Route 53. Ultimately, it will involve (a lot of) glue code/config depending on what solution you go ahead with.
In Ask HN: What's a good open-source alternative to Cloudflare?
Is anyone on HN doing WordPress administration? I recently 'inherited' a webshop built on WP/WooCommerce, and all the conflicting security advice in the WP space is making my head spin. There are a dozen competing 'security' plugins, with some saying 'you don't need any of them, WP is secure enough by default', and others saying 'you actually need ModSecurity [1] / Jeff Starr's nG firewall [2] on your server'. The agency that (shoddily...) built the webshop installed Wordfence Free [3], so I've just kept that for now, though I feel it's kind of slow (but that might just be caused by the bottom-of-barrel performance of the shared webhost it's currently running on). [1] https://github.com/SpiderLabs/ModSecurity [2] https://perishablepress.com/7g-firewall/ [3] https://www.wordfence.com/
In WordPress sites getting hacked ‘within seconds’ of TLS certificates being issued

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.