2
3
I configured my Apache server as a proxy server. I added some filters to my proxy.conf
file to change the text (HTML source code) of the websites.
Example code:
ExtFilterDefine foodo mode=output intype=text/html
cmd="/bin/sed -r 's/foo/newfoo/g'"
SetOutputFilter foodo
I have enabled also every possible mods for that. (mod_proxy
, mod_proxy_html
, ...)
After I used also mod_sed
to change some text but still I have no positive solution.
<Directory "/var/www/docs/sed">
AddOutputFilter Sed html
OutputSed "s/monday/MON/g"
OutputSed "s/sunday/SUN/g"
</Directory>
Here is my proxy.conf:
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>
Do anyone have any idea for this problem?
Thank you so much for this answer. I had a feeling that gzip was causing the issue so I tried AddOutputFilterByType INFLATE to fix this. But although now response wasn't gzipped still substitute was not working. I tried you technique and it worked. – Yash Agarwal – 2015-05-19T10:01:27.337
Getting an error on the first FilterProvider line: "FilterProvider takes three arguments, filter-name provider-name match-expression" – cmcginty – 2016-02-05T00:50:06.027
Yep i tried that also today!
sudo a2enmod substitute
and then<Location /> AddOutputFilterByType SUBSTITUTE text/html Substitute s/foo/bar/ni </Location>
and then i restarted my apache server! Then when i visited the website from the client side and look up the source code "foo" is still there. – xmux – 2014-06-11T13:56:18.633And also my proxy.conf file looks like that:
ProxyRequests On ProxyVia On <Proxy *> Order deny,allow Deny from all Allow from all </Proxy>
– xmux – 2014-06-11T13:59:33.520@xmux I've updated my post with a config that is tested and works for me. – mtak – 2014-06-11T14:21:18.397
Thanks! but then this one is the 000-default.conf file and i want still a proxy server actually. And i am using apache 2.4, does it make any difference? – xmux – 2014-06-11T14:26:13.493
It is a piece of the total Apache config. If you put this anywhere in your Apache config (or in
/etc/(apache2|httpd)/sites-enabled
), it will make virtualhost su-test.int.mtak.nl a proxy. – mtak – 2014-06-11T14:29:17.7372You were totaly right about this "RequestHeader unset Accept-Encoding" after that i just updated my proxy.conf with <Location /> AddOutputFilterByType SUBSTITUTE text/html Substitute s/foo/bar/ni </Location> and it just worked! Thanks a lot! if you want, you can change the answer to a normal substitute example. – xmux – 2014-06-11T14:44:38.190