I am trying to do search and replace operation on response bodies using a transparent apache reverse proxy configuration, the below config using "mod_substitute" and "mod_proxy" works as expected :
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
ProxyRequests Off
<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>
ProxyPass / http://thedomain.ineed.proxied/
ProxyPassReverse / http://thedomain.ineed.proxied/
# Set location
<location />
SetOutputFilter INFLATE;SUBSTITUTE;DEFLATE
Substitute "s|<script src=\"http://static.ak.fbcdn.net/connect.php/js/FB.Share\" type=\"text/javascript\"></script>| |niq"
</location>
</VirtualHost>
Now the problem is I need to remove a lot of garbage from the upstream proxied server response body and mod_substitute only provides line-by-line processing which is neither efficient not practical. Any alternative modules or methods to solve this ?
Best Answer
What I needed was easily implementable using nginx and this module - https://github.com/agentzh/replace-filter-nginx-module