Apache2-ModProxyPerlHtml
view release on metacpan or search on metacpan
ModProxyPerlHtml.pm view on Meta::CPAN
Some MS Office files may conflict with the above ProxyHTMLContentType regex like .docx or .xlsx
files. The result is that there could suffer of replacement inside and the file will be corrupted.
to prevent this you have the ProxyHTMLExcludeContentType configuration directive to exclude certain
content-type. Here is the default value:
PerlAddVar ProxyHTMLExcludeContentType (application\/vnd\.openxml)
If you have problem with other content-type, use this directive. For example, as follow:
PerlAddVar ProxyHTMLExcludeContentType (application\/vnd\.openxml|application\/vnd\..*text)
this regex will prevent any MS Office XML or text document to be parsed.
Some javascript libraries like JQuery are wrongly rewritten by ModProxyPerlHtml.
The problem is that those javascript code include some code and regex that are
detected as links and rewritten. The only way to fix that is to exclude those
files from the URL rewritter by using the "ProxyHTMLExcludeUri" configuration
directive. For example:
PerlAddVar ProxyHTMLExcludeUri jquery.min.js$
PerlAddVar ProxyHTMLExcludeUri ^.*\/jquery-lib\/.*$
Any downloaded URI that contains the given regex will be returned asis without
rewritting. You can use this directive multiple time like above to match different
cases.
=head1 LIVE EXAMPLE
Here is the reverse proxy configuration I use to give access to Internet users
to internal applications:
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass /webmail/ http://webmail.domain.com/
ProxyPass /webcal/ http://webcal.domain.com/
ProxyPass /intranet/ http://intranet.domain.com/
PerlInputFilterHandler Apache2::ModProxyPerlHtml
PerlOutputFilterHandler Apache2::ModProxyPerlHtml
SetHandler perl-script
# Use line below iand comment line above if you experience error:
# "Attempt to serve directory". The reason is that with SetHandler
# DirectoryIndex is not working
# AddHandler perl-script *
PerlSetVar ProxyHTMLVerbose "On"
LogLevel Info
# URL rewriting
RewriteEngine On
#RewriteLog "/var/log/apache/rewrite.log"
#RewriteLogLevel 9
# Add ending '/' if not provided
RewriteCond %{REQUEST_URI} ^/mail$
RewriteRule ^/(.*)$ /$1/ [R]
RewriteCond %{REQUEST_URI} ^/planet$
RewriteRule ^/(.*)$ /$1/ [R]
# Add full path to the CGI to bypass the index.html redirect that may fail
RewriteCond %{REQUEST_URI} ^/calendar/$
RewriteRule ^/(.*)/$ /$1/cgi-bin/wcal.pl [R]
RewriteCond %{REQUEST_URI} ^/calendar$
RewriteRule ^/(.*)$ /$1/cgi-bin/wcal.pl [R]
<Location /webmail/>
ProxyPassReverse /
PerlAddVar ProxyHTMLURLMap "/ /webmail/"
PerlAddVar ProxyHTMLURLMap "http://webmail.domain.com /webmail"
# Use this to disable compressed HTTP
#RequestHeader unset Accept-Encoding
</Location>
<Location /webcal/>
ProxyPassReverse /
PerlAddVar ProxyHTMLURLMap "/ /webcal/"
PerlAddVar ProxyHTMLURLMap "http://webcal.domain.com /webcal"
</Location>
<Location /intranet/>
ProxyPassReverse /
PerlAddVar ProxyHTMLURLMap "/ /intranet/"
PerlAddVar ProxyHTMLURLMap "http://intranet.domain.com /intranet"
# Rewrite links that give access to the two previous location
PerlAddVar ProxyHTMLURLMap "/intranet/webmail /webmail"
PerlAddVar ProxyHTMLURLMap "/intranet/webcal /webcal"
</Location>
This gives access two a webmail and webcal application hosted internally to all
authentified users through their own Internet acces. There's also one acces to
an Intranet portal that have links to the webcal and webmail application. Those
links must be rewritten twice to works.
=head1 ROT13 obfuscation
Some links can be obfucated to be hidden from google or other robots. To enable
encode/decode of those links you can use the ProxyHTMLRot13Links directive as
follow:
PerlAddVar ProxyHTMLRot13Links All
All links in the page will be decoded before being rewritten and re-encoded.
If obfuscation occurs on some attributs only you can set the value as a pair
of element:attribut where the decoding/encoding must be applied. For example:
PerlAddVar ProxyHTMLRot13Links a:data-href
PerlAddVar ProxyHTMLRot13Links a:href
=head1 BUGS
Apache2::ModProxyPerlHtml is still under development and is pretty
stable. Please send me email to submit bug reports or feature
requests.
=head1 COPYRIGHT
Copyright (c) 2005-2022 - Gilles Darold
All rights reserved. This program is free software; you may redistribute
( run in 0.451 second using v1.01-cache-2.11-cpan-df04353d9ac )