Mailing List Archive

cannot get mod_substitute to substitute in response from remote server in reverse proxy setup
Trying to get mod_substitute to work for me in a reverse proxy setup
and having troubles, specifically the substitution in not occurring in
responses from the remote server. Basically my browser clients are
contacting my Apache setup at help-proxy.asperasoft.com and are being
reverse proxied to help.asperasoft.com. I want to perform
substitutions in the response that comes back from that remote HTTP
server (help.asperasoft.com) before the response is passed back to the
browser. (Note that help-proxy.asperasoft.com is not accessible from
the Internet, it's internal to my company...)

I tried using mod_substitute and it seems to not be doing
substitutions in the contents being returned from the remote server.
It is doing substitutions in content begin returned from Apache
itself. I see this by having made a substitution to the Apache Test
Page and if I go to http://help-proxy.asperasoft.com/ I see the
substitution is made. But if I go to
http://help-proxy.asperasoft.com/discussions, the content of which is
reverse proxied from help.asperasoft.com, the substition is not made
even though "Public Discussion" is in the response document:

<li class="public_issues"><a href="/discussions">Public
Discussion</a></li>
and...
<h1>Public Discussion</h1>

Any thoughts about what might be happening here or how I can go about
debugging this? If nod_substitute can't work in this way, any
suggestions about what might work?

Thanks in advance...

Chris

* * *

Here's the virtual host-related part of my config:

#
# stuff for testing

LoadModule substitute_module modules/mod_substitute.so

NameVirtualHost *:80

<VirtualHost *:80>
LogLevel debug

</VirtualHost>

<VirtualHost *:80>
ServerName help-proxy.asperasoft.com
LogLevel debug

ProxyPass /discussions http://help.asperasoft.com/discussions
[...]
ProxyPass /faqs http://help.asperasoft.com/faqs
ProxyPass /images http://help.asperasoft.com/images
ProxyPass /setup http://help.asperasoft.com/setup
ProxyPass /marketing http://help.asperasoft.com/marketing
ProxyPass /stylesheets http://help.asperasoft.com/stylesheets
ProxyPass /login http://help.asperasoft.com/login

AddOutputFilterByType SUBSTITUTE text/html
Substitute "s/Public Discussion/Public Discussion Boo Yah/"
Substitute "s/Apache Test Page/Apache Test Page Boo Yah/"

</VirtualHost>

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: cannot get mod_substitute to substitute in response from remote server in reverse proxy setup [ In reply to ]
On Thu, 28 Oct 2010 14:13:56 -0700
Chris Markle <cmarkle@asperasoft.com> wrote:


> AddOutputFilterByType SUBSTITUTE text/html

That's probably your problem. In a proxy (or dynamic page) the
content-type is unknown at the point where that is set.

Use mod_filter instead.

--
Nick Kew

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: cannot get mod_substitute to substitute in response from remote server in reverse proxy setup [ In reply to ]
Nick,

> Use mod_filter instead.

Thanks for that good suggestion. I worked something up to test this
with mod_filter and mod_substitute and it seems to be working. Just
including my config here for the next poor sap that has this question.
Thanks again...

Chris

* * *

/etc/httpd/conf.d/replace.conf:

#
# Chris stuff for testing of replace via filter

#SetEnv filter_errordocs

LoadModule substitute_module modules/mod_substitute.so
LoadModule filter_module modules/mod_filter.so

FilterDeclare replace
FilterProvider replace SUBSTITUTE Content-Type $text/html
FilterChain +replace
# for logging (not sure how helpful the logging is...)
FilterTrace replace 1
Substitute "s/Apache HTTP Server Version/Apache HTTP Server Version Boo Yah/n"

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org