1

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.

Toby Hede
  • 309
  • 5
  • 11

2 Answers2

1

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.

coredump
  • 12,713
  • 2
  • 36
  • 56
  • 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 01 '11 at 03:37
  • @Toby it sounds kind of illegal to me too. Kind of tampering. But law varies from place to place. – coredump Apr 01 '11 at 03:38
  • We own all of the domains in question. – Toby Hede Apr 01 '11 at 03:41
1

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

Aivars
  • 11
  • 2