-
Notifications
You must be signed in to change notification settings - Fork 302
Hook into Nginx NGX_HTTP_ACCESS_PHASE #361
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
base: master
Are you sure you want to change the base?
Conversation
|
Hi @tomsommer! Thanks for this PR. Could you add some test(s) (see others here) to check that the behavior is that the modification expects? I mean set up the engine with some very low rate limit and try to send more parallel requests than that. Or you can add a new job in our workflow. Thanks again! |
|
What do you want to test? It sounds like you want to test if Nginx limit_* works? |
No, I want to test if this patch solves the mentioned issue and that you wrote (in a removed comment): "nginx cannot survive a DDOS if modsec is before limit*". It would be nice to see that if the user sets a limit and requests exceed then Nginx drops the connections and the requests do not reach ModSecurity.
Yes, that's a necessary but not sufficient condition. |
|
I did a lot of testing and I had to merge the rewrite stuff into the access handler, instead of registering two handlers in the same phase (I don't know if it's the order, or whatever), but it works now. It runs after limit_* |
|
|
Hi @tomsommer, first of all, many thanks for your fix, and apologize for the late response. I think this is a very important solution.
I saw the tests - thanks for them - which justify the code works as well. Thank you for them too. I'm still a little worried (I'm not an Nginx developer), because:
If we are lucky now, @defanator will see this comment and may be he will explain the reason. If there won't be any response or other discussion, I'll merge this into the master, and hopefully many people will test that, which will provide some feedback (as it happened in case of #334 which was reverted in #344). |



Hook into Nginx
NGX_HTTP_ACCESS_PHASEinstead ofNGX_HTTP_PREACCESS_PHASEandNGX_HTTP_REWRITE_PHASE.Having ModSecurity run before
NGX_HTTP_ACCESS_PHASEcripples Nginx during DDOS attacks, because ModSecurity runs before Nginx limit_* functions and consumes too much CPU/memory even in phase:1.Fixes #293