Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am experimenting with using Varnish as a proxy to inject some HTML into pages from specific domains.

So if any page is coming from *.organisation.edu.au, force a snippet of html immediately after the body tag. For extra points, if the system was smart enough to detect that the html was already present and NOT include the snippet, that would be totes awesome.

I am working through the varnish docs, but any help or pointers would be greatly appreciated.

Open to other suggestions for handling this requirement as well.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

I don't think that can be done with varnish, at least I can't remember of anything on it's documentation about that and it would be pretty strange for a proxy to inject something other than headers on it's response.

Also, injecting HTML outside the backend can break the page in many ways, so you must be very sure that you really want to do that. The most appropriate form I can think would be to add that at the application or template level, but not after the page has been rendered.

share|improve this answer
    
Yep. It's pretty strange. I work for a (very) large educational institution, and we have hundreds if not thousands of distinct sites, all driven by different technologies, so application level is very problematic as well. –  Toby Hede Apr 1 '11 at 3:37
    
@Toby it sounds kind of illegal to me too. Kind of tampering. But law varies from place to place. –  coredump Apr 1 '11 at 3:38
    
We own all of the domains in question. –  Toby Hede Apr 1 '11 at 3:41

I've written a VMOD to modify response body, use it at your own risk https://github.com/aivarsk/libvmod-rewrite

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.