Adding some content to html response

I would like to know is it possible to achieve with (my guess is) a proxy server to add some content to users response?

Let’s say I would like to add a div to each html document which is being opened by users of my local network. So what I’m looking for is some sort of a intermediary server. It might be just my imagination that something like this exists, but if it does could you tell me the technical name of the functionality that I’m looking for? Any free/open source solutions?

Greetings, and thank you for answers.

Answer

You don’t say but if you’re using Apache you can use the mod_substitute module to accomplish this. Check out the Apache documentation and also this example.

The steps will be roughly:

  • Add the mod_substitute directive to Apache configuration files.
  • Add a rule

Example rule

<Location />

AddOutputFilterByType SUBSTITUTE text/html
Substitute 's|</body>|<script src="https://xxx.com/myBucket/cookiepolicy.js" type="text/javascript"></script></body>|ni'
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript

</Location>

Attribution
Source : Link , Question Author : mike , Answer Author : slm

Leave a Comment