nginx hackery : change image file every X request

Posted by Vangel on Server Fault See other posts from Server Fault or by Vangel
Published on 2011-11-19T10:11:13Z Indexed on 2011/11/19 17:56 UTC
Read the original article Hit count: 228

Let me describe what I am trying to do first.

I have a bunch of pictures in a directory called /images/*.(jpg|gif|png|blah blah|)

Now say these images are embedded in an html page and I dont really care which image or where its embedded.

For every 10th request for the same picture file (if possible) or for any picture I want to display a fixed image (e.g. trollface.jpg). thats it!

I have searched around a bit but i am not even sure what I am looking for. Rewrite might help but then its a permanent thing. this has got to do something with requests. I have heard perl scripts can be used with nginx. I can't write an nginx module (though I did bravely lookup the docs and then gave up)

Before you ask "But why don't you do it in application, noob?". This is a static files only server. The point is to not execute any binary at all.

© Server Fault or respective owner

Related posts about nginx

Related posts about images