Nginx – Necesity of ModSecurity if Apache is behind Nginx

apache-2.2mod-securitynginxSecurity

I have my Apache installed behind Nginx. So every request that comes in is first handeled by Nginx. If there is dynamic content needed the request is send to Apache which listens on port 8080.

Pretty basic reverse proxy setup.

Now with this setup the first entry point is Nginx. Is it still needed to install ModSecurity to protect Apache against unwanted request.

Or should I just focus on protecting Nginx as this is the first entry point.

All suggestions are welcome.

Best Answer

I would say yes to hardening NginX as much as possible and yes to using ModSecurity on the Apache server if your site is hosting any sort of webapp or dynamic content that can be contributed by the end users, such as comments. Pretty much if your website has forms then ModSecurity is a good idea.

ModSecurity doesn't protect Apache per-say. It protects the webapps and forms that it's serving from exploitation. So it's purpose is to help protect the website from XSS, SQL Injection, and CSRF/XSRF attacks.

Related Topic