Rewriting html links with modproxyperlhtml
Posted
by
Juancho
on Server Fault
See other posts from Server Fault
or by Juancho
Published on 2012-11-15T23:32:20Z
Indexed on
2012/11/20
23:05 UTC
Read the original article
Hit count: 355
I'm trying to setup an Apache reverse proxy using mod_proxy and modproxyperlhtml. This is my scenario:
Domain for the proxy: http : // www.myserver.com/ Destination server (the one behind the proxy): http : // myserver.foo.com/myapp/
I'm sorry that I have to space the URL but serverfault doesn't allow me to post more than two links as "spam protection mechanism" (ridiculous on a site where you ask questions about servers and it's really probable to post more than two times the same URL's to explain your question).
The idea is to map http : // www.myserver.com/ to http : // myserver.foo.com/myapp/ . Note that the path on the proxy is / and on the destination server is /myapp/. All of the examples I can find on the net (like the one on the official documentation of modproxyperlhtml) are the other way around, ie. path on the proxy /myapp/ and path on the destination server /. This is my current config that doesn't work:
ProxyPass / http : // myserver.foo.com/myapp/
ProxyPassReverse / http : // myserver.foo.com/myapp/
PerlInputFilterHandler Apache2::ModProxyPerlHtml
PerlOutputFilterHandler Apache2::ModProxyPerlHtml
SetHandler perl-script
PerlSetVar ProxyHTMLVerbose "On"
LogLevel Info
<Location / >
# ProxyPassReverse /myapp/
PerlAddVar ProxyHTMLURLMap "/myapp/ /"
PerlAddVar ProxyHTMLURLMap "http : // myserver.foo.com /"
</Location>
The examples use the ProxyPassReverse inside the Location directive, but on my case doesn't work, only when outside. With this configuration the links aren't being replaced as they should be, my guess is that the location isn't being found, thus the rewrite rules aren't being applied. The error log only shows that it uncompresses the content, searches it but doesn't find anything:
[Tue Nov 13 0842:05 2012] [warn] [ModProxyPerlHtml] Uncompressing text/html; charset=UTF-8, Content-Encoding: gzip\n
[Tue Nov 13 08:42:05 2012] [warn] [ModProxyPerlHtml] Content-type 'text/html; charset=UTF-8' match: /(text\\/javascript|text\\/html|text\\/css|text\\/xml|application\\/.*javascript|application\\/.*xml)/is\n
[Tue Nov 13 08:42:05 2012] [warn] [ModProxyPerlHtml] Compressing output as Content-Encoding: gzip\n
[Tue Nov 13 08:42:06 2012] [warn] [ModProxyPerlHtml] Content-type 'text/html; charset=UTF-8' match: /(text\\/javascript|text\\/html|text\\/css|text\\/xml|application\\/.*javascript|application\\/.*xml)/is\n
What could be wrong ?
© Server Fault or respective owner