Security – Apache – Drop connection for anything but HTTP 200 status

apache-2.2apache-2.4Security

Is there a way to configure Apache to drop connection for any request resulting in an HTTP status other than 200 (or possibly a list of status codes)? The idea is that, rather than returning any information to a hacker probing the server, just terminate the connection when an invalid request is made. I'm thinking about something similar to iptables DROP rules, but at the application layer.

I realize this would not be a substitute to other security measures (firewall, reverse proxy, mod_security, access control, non-default error pages, etc), but it would be an additional measure.

Best Answer

You could make 403 return a 404 page & status code (make sure it's both!), which would throw off people snooping around. I believe Google and many other large sites do this. However, dropping the connection after an error like this is not helpful (and can even be harmful).