0

Is there any module for Apache that would block clients that do not ask for graphic elements (jpg, gif, css) at all? This of course would have to work by analysing many successful http request and blocking if there were more than X request and ration of graphics downloads below X %

2
  • This would be a pretty mean thing to do to the blind/visually impaired community. Quite possibly illegal in some countries for that reason.
    – ceejayoz
    Sep 12, 2014 at 14:29
  • 1
    What you are trying to accomplish with this? Avoid being crawled by bots? Reducing spam? Or something else?
    – ThoriumBR
    Sep 12, 2014 at 14:33

3 Answers 3

1

No. HTTP clients will first request the HTML content and work their one through that, requesting other objects that are required to render the page as specified.

It's perfectly fine for a HTTP client not to request any graphic elements if it already has them cached.

Whatever you're trying to do, it won't work that way.

0

This is not a good idea. Proxies can send the requests to various upstream proxies, caching can prevent download of some resources, users navigating with restricted resources (like cellphone) can disable download of pictures, and other technical problems around the way will prevent you for doing whatever you are wanting to do.

If you want to go ahead anyway, you will not be able to do this with Apache alone, but you can do it with the help of a log parser.

You will have to parse the log files for every request made by a certain IP address, count all the text requests (HTML, scripts, CSS, XML) and the graphic elements. If the ratio of text/graphic is bellow a certain treshold, you can block the client by adding its IP to your .htaccess file:

Order Deny,Allow
Deny from 50.60.70.80
Deny from 80.70.60.50

Be aware that if some blocked user is behind NAT or proxy, you will block an entire network from accessing your site.

You can write mod_rewrite to create a more fine-grained block. Get the combination of IP address, User Agent and a custom cookie. Block this combination.

This site have 8 ways to blacklist a user. It can be useful.

0

Besides the other answers here, note that there are still people using text-based browsers such as lynx or w3m, and those clients will never download images.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .