This diff backports and documents the ProxyPass negation found in apache2, useful for excluding subdirs from being proxied, e.g.
ProxyPass /foo/bar ! ProxyPass /foo/ http://backend/foo/ I run this patch in production on a loaded i386 reverse proxy without any troubles. Spacing corrections by st...@. Index: htdocs/manual/mod/mod_proxy.html =================================================================== RCS file: /cvs/src/usr.sbin/httpd/htdocs/manual/mod/mod_proxy.html,v retrieving revision 1.9 diff -u -r1.9 mod_proxy.html --- htdocs/manual/mod/mod_proxy.html 1 Aug 2006 12:53:59 -0000 1.9 +++ htdocs/manual/mod/mod_proxy.html 5 Aug 2009 12:17:58 -0000 @@ -467,7 +467,7 @@ directive</h2> <a href="directive-dict.html#Syntax" rel="Help"><strong>Syntax:</strong></a> ProxyPass <em>path - url</em><br /> + !|url</em><br /> <a href="directive-dict.html#Default" rel="Help"><strong>Default:</strong></a> <em>None</em><br /> <a href="directive-dict.html#Context" @@ -499,6 +499,19 @@ <<samp>http://wibble.org/mirror/foo/bar</samp>> to be internally converted into a proxy request to <<samp>http://foo.com/bar</samp>>.</p> + + <p>The <code>!</code> directive is useful when you don't want + to reverse-proxy a subdirectory, <em>e.g.</em></p> +<pre> + ProxyPass /mirror/foo/bar ! + ProxyPass /mirror/foo http://backend.site.com +</pre> + <p>will proxy all requests to <samp>/mirror/foo</samp> to + <samp>backend.site.com</samp> <em>except</em> requests made to + <samp>/mirror/foo/bar</samp>.</p> + + <p><strong>Note:</strong> Order is important. You need to put the + exclusions <em>before</em> the general ProxyPass directive.</p> <p><strong>Warning:</strong> The <code><a href="#proxyrequests">ProxyRequests</a></code> directive should Index: src/modules/proxy/mod_proxy.c =================================================================== RCS file: /cvs/src/usr.sbin/httpd/src/modules/proxy/mod_proxy.c,v retrieving revision 1.16 diff -u -r1.16 mod_proxy.c --- src/modules/proxy/mod_proxy.c 9 May 2008 08:06:28 -0000 1.16 +++ src/modules/proxy/mod_proxy.c 5 Aug 2009 12:17:58 -0000 @@ -200,6 +200,10 @@ len = alias_match(r->uri, ent[i].fake); if (len > 0) { + if ((ent[i].real[0] == '!') && (ent[i].real[1] == 0)) { + return DECLINED; + } + r->filename = ap_pstrcat(r->pool, "proxy:", ent[i].real, r->uri + len, NULL); r->handler = "proxy-server";
