From: Jeff Trawick Date: Sat, 21 Jun 2014 13:47:30 +0000 (+0000) Subject: Merge r1573626 from trunk: X-Git-Tag: 2.4.10~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e15baf150df30c9d2298e8f19894e32ee9c18fc;p=apache Merge r1573626 from trunk: mod_proxy: Allow reverse-proxy to be set via explicit handler. Submitted by: ryo takatsuki Reviewed by: ylavic, jim, mrumph git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1604378 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index ea9b371bed..e02a3cad26 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.4.10 + *) mod_proxy: Allow reverse-proxy to be set via explicit handler. + [ryo takatsuki ] + *) ab: support custom HTTP method with -m argument. PR 56604. [Roman Jurkov ] diff --git a/STATUS b/STATUS index 03f11ecfd1..26c679fb08 100644 --- a/STATUS +++ b/STATUS @@ -100,14 +100,6 @@ RELEASE SHOWSTOPPERS: PATCHES ACCEPTED TO BACKPORT FROM TRUNK: [ start all new proposals below, under PATCHES PROPOSED. ] - * mod_proxy: Allow reverse-proxy to be set via explicit handler. - Submitted by: [ryo takatsuki ] - Committed by: jim - trunk patch: http://svn.apache.org/r1573626 - 2.4.x patch: trunk works - +1: ylavic, jim, mrumph - mrumph: Verified on Linux with mod_proxy_fcgi and PHP FPM. - * mod_deflate: Fix decompression of files larger than 4GB. According to RFC1952, Input SIZE contains the size of the original input data modulo 2^32. PR 56062. diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index e1f90c05b8..1b68bf8df6 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -171,6 +171,23 @@ ProxyVia On +
Access via Handler + +

You can also force a request to be handled as a reverse-proxy + request, by creating a suitable Handler pass-thru. For example, + the below will pass all PHP scripts to the specified + reverse-proxy FCGI server: +

+ + Reverse Proxy PHP scripts + +<FilesMatch \.php$> + SetHandler "proxy:unix:/path/to/app.sock|fcgi://localhost/" +</FilesMatch&lgt; + + +
+
Workers

The proxy manages the configuration of origin servers and their diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index 57f9e41b87..b331a6c545 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -927,8 +927,25 @@ static int proxy_handler(request_rec *r) struct dirconn_entry *list = (struct dirconn_entry *)conf->dirconn->elts; /* is this for us? */ - if (!r->proxyreq || !r->filename || strncmp(r->filename, "proxy:", 6) != 0) + if (!r->filename) { + return DECLINED; + } + + if (!r->proxyreq) { + /* We may have forced the proxy handler via config or .htaccess */ + if (r->handler && + strncmp(r->handler, "proxy:", 6) == 0 && + strncmp(r->filename, "proxy:", 6) != 0) { + r->proxyreq = PROXYREQ_REVERSE; + r->filename = apr_pstrcat(r->pool, r->handler, r->filename, NULL); + apr_table_setn(r->notes, "rewrite-proxy", "1"); + } + else { + return DECLINED; + } + } else if (strncmp(r->filename, "proxy:", 6) != 0) { return DECLINED; + } /* handle max-forwards / OPTIONS / TRACE */ if ((str = apr_table_get(r->headers_in, "Max-Forwards"))) {