]> granicus.if.org Git - apache/commitdiff
Merge r1573626 from trunk:
authorJeff Trawick <trawick@apache.org>
Sat, 21 Jun 2014 13:47:30 +0000 (13:47 +0000)
committerJeff Trawick <trawick@apache.org>
Sat, 21 Jun 2014 13:47:30 +0000 (13:47 +0000)
mod_proxy: Allow reverse-proxy to be set via explicit handler.

Submitted by: ryo takatsuki <ryotakatsuki gmail com>
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

CHANGES
STATUS
docs/manual/mod/mod_proxy.xml
modules/proxy/mod_proxy.c

diff --git a/CHANGES b/CHANGES
index ea9b371bed22bbd4cf4d912bc36bcd58328a2589..e02a3cad26bcecfb2131985dea70008277c636da 100644 (file)
--- 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 <ryotakatsuki gmail com>]
+
   *) ab: support custom HTTP method with -m argument. PR 56604.
      [Roman Jurkov <winfinit gmail.com>]
 
diff --git a/STATUS b/STATUS
index 03f11ecfd1d807a360a5b76e61e550ea636289b8..26c679fb08bedce9cd759a585d940d1f3ee8ed91 100644 (file)
--- 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 <ryotakatsuki gmail com>]
-     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.
index e1f90c05b820ead533a9ade10c94f3381b04918b..1b68bf8df619525995e80d8879351ad70888a9e0 100644 (file)
@@ -171,6 +171,23 @@ ProxyVia On
     </example>
     </section> <!-- /examples -->
 
+    <section id="handler"><title>Access via Handler</title>
+
+    <p>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:
+    </p>
+
+    <example><title>Reverse Proxy PHP scripts</title>
+    <highlight language="config">
+&lt;FilesMatch \.php$&gt;
+    SetHandler  "proxy:unix:/path/to/app.sock|fcgi://localhost/"
+&lt;/FilesMatch&lgt;
+    </highlight>
+    </example>
+    </section> <!-- /handler -->
+
 
     <section id="workers"><title>Workers</title>
       <p>The proxy manages the configuration of origin servers and their
index 57f9e41b8718d8926843e1c19cf8b80c8b7b9d77..b331a6c545ba68b21b1dea27c6fdcdaeb8f7ff4b 100644 (file)
@@ -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"))) {