NAME

Apache::ProxyRewrite - mod_perl URL-rewriting proxy

SYNOPSIS

<Location    />
SetHandler   perl-script
PerlHandler  Apache::ProxyRewrite

PerlSetVar   ProxyTo           http://www.tivoli.com
PerlSetVar   ProxyAuthInfo     "BASIC aGb2c3ewenQ6amF4szzmY3b="
PerlSetVar   ProxyAuthRedirect On
PerlSetVar   ProxyRewrite      "https://www.tivoli.com/secure => /secure"
</Location>

<Location    /secure>
SetHandler   perl-script
PerlHandler  Apache::ProxyRewrite

PerlSetVar   ProxyTo           https://www.tivoli.com/secure
PerlSetVar   ProxyAuthInfo     "BASIC aGb2c3ewenQ6amF4szzmY3b="
PerlSetVar   ProxyAuthRedirect Off
PerlSetVar   ProxyRewrite      "http://www.tivoli.com/ => /"
</Location>

DESCRIPTION

Apache::ProxyRewrite acts as a reverse-proxy that will rewrite URLs embedded in HTML documents per apache configuration directives.

This module was written to allow multiple backend services with discrete URLs to be presented as one service and to allow the proxy to do authentication on the client's behalf.

CONFIGURATION OPTIONS

The following variables can be defined within the configration of Directory, Location, or Files blocks.

ProxyTo

The URL for which ProxyRewrite will proxy its requests.

ProxyAuthInfo

Authorization information for proxied requests. This string must conform to the credentials string defined in section 11 of RFC 2068.

ProxyAuthRedirect

If the credentials supplied in the ProxyAuthInfo directive are insufficient and if ProxyAuthRedirect is set to On, the proxy server will redirect the client directly to the backend host. If ProxyAuthRedirect is set to Off (the default), the proxy server will challenge the client on the remote server's behalf.

ProxyRewrite

A hash of URLs to rewrite. A note on hashes in configuration directives from the "Writing Apache Modules with Perl and C" book page 287:

The only trick is to remember to put double quotes around the
configuration value if it contains whitespace and not to allow
your text editor to wrap it to another line. You can use
backslash as a continuation character if you find long lines a
pain to read.

NOTES

Automatic mappings

ProxyRewrite automatically adds a mapping for the remote relative URI and the current location. An example:

ServerName   proxyhost

<Location    /foo>
PerlSetVar   ProxyTo   http://server1/A
</Location>

The request for http://proxyhost/foo/B is proxied to http://server1/A/B. Within the response from server1 is an embedded URI /A/C. This URI is rewritten to /foo/C before being returned to the client.

Embedded Languages

Embedded languages such as Javascript are not parsed for embedded URLs. The problem is NP-Complete. The best choice is to surround all embedded languages in HTML comments to avoid possible parsing problems.

Parser Notes

The parser takes a single pass through each HTML document. This method is extremely efficient, but it has possible drawbacks with poorly constructed HTML. All known drawbacks have been eliminated, but more may exist. Please contact the author if you have any trouble with parsed output.

Special Thanks

A special thanks goes to my co-authors of absent, from which much of the rewriting code comes, Dave Korman and Avi Rubin. Absent is a system for secure remote access to an organization's internal web from outside its firewall. To learn more about absent, go to http://www.research.att.com/projects/absent/.

AVAILABILITY

This module is available via CPAN at http://www.cpan.org/modules/by-authors/id/C/CG/CGILMORE/.

AUTHOR

Christian Gilmore <cag@us.ibm.com>

SEE ALSO

httpd(8), mod_perl(1)

COPYRIGHT

Copyright (C) 2002, International Business Machines Corporation and others. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the terms of the IBM Public License.