Forum Discussion
Darren_Person_2
Nimbostratus
May 07, 2007Image Leeching / Random querystring fix?
Hi All,
We have the RAMCACHE module installed and are seeing a high rate of evictions. After some further investigation, it appears that we have someone linking to our images using a random querystring (i.e.: http://site.com/img/image.jpg?random=XXXXXX
This is generating many copies of this image in our cache. Can someone explain a possible iRule solution to strip off the querystring an make it so that they can no longer do this?
In addition, do you know of any iRule which would stop someone from leeching our images. i.e.: If the image isn't being requested from one of our domains in the browser url, then send back a fake image?
Any help you could provide would be greatly appreciated!!
- bl0ndie_127134Historic F5 AccountCheck out example on using CACHE::uri if you are using 9.2 or later release. This rule sets the effective URI without modifying it on the wire.
- Kirk_Bauer_1018
Nimbostratus
You could definitely check to see if the URI requested contains the string ".jpg" and then check the "Referer" (sic) header and check to see if it comes from your sites. I don't have time to write it for you, but it should be pretty straightforward to do this sort of rule. - hoolio
Cirrostratus
There is a related example in the codeshare for restricting access to specific file types using the referer header. - Darren_Person_2
Nimbostratus
Hi All, - hoolio
Cirrostratus
'[string first {?} $myUri 0]' will return an index of the first occurrence of the ? character. You could use that index in string range to get all characters up to that index: - Darren_Person_2
Nimbostratus
Thanks Aaron - so would this work: - hoolio
Cirrostratus
I haven't used the CACHE:: functions before as I haven't had a license for it, and I couldn't find any example rules that used CACHE::uri so I'm not very clear on the commands. But based on Bl0ndie's post (Click here), I don't think any change is made to the actual request. The change is just to what the caching module logically parses the request as. - Darren_Person_2
Nimbostratus
I've tried to update it as follows, but I'm still seeing the cache build up on requests: - Darren_Person_2
Nimbostratus
When I do that, I get the following error: - hoolio
Cirrostratus
Are you on 9.2 or higher? It looks like the CACHE::uri command was added in 9.2.0.when HTTP_REQUEST { if {[HTTP::uri] contains "?"}{ CACHE::uri [HTTP::host][HTTP::path] } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects