Dorian Taylor
and 1 contributors


Apache2::CondProxy - Intelligent reverse proxy for missing resources


Version 0.14


    # httpd.conf
    PerlFixupHandler Apache2::CondProxy
    PerlSetVar ProxyTarget
    PerlSetVar RequestBodyCache /tmp


This module performs the logic required to achieve what is implied by the following Apache configuration:

    # httpd.conf
    RewriteEngine On
    RewriteCond %{REQUEST_URI} !-U
    RewriteRule (.*)$1 [P,NS]

Which says if I can't respond to a given request, try Unfortunately, the architecture of mod_rewrite, as well as the design of Apache's handler model itself, prohibits this. In the first case, all RewriteCond directives are evaluated after the associated RewriteRule. In the second, the response code is initialized to 200 and remains that way until it is changed, most likely by a response handler which never gets run. This confluence of behaviour makes the above configuration not do what we imagine it would.

This module works by running the request all the way through in a subrequest. Before doing so, a filter is installed to trap the subrequest's response. If the response is unsuccessful, specifically if it is a 403 or 404, the filter disposes of the error body, and the request is forwarded to the proxy target. The proxy URI scheme is matched to the original request URI scheme, so make sure you have SSLProxyEngine on.

If a proxy response contains a Location header, and its host is the same as the proxy target, that header will be rewritten to point to the source host.


Dorian Taylor, <dorian at>


Please report any bugs or feature requests to bug-apache2-filterfun at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Apache2::CondProxy

You can also look for information at:


Copyright 2013 Dorian Taylor.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at .

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.