From cd304f49642f15967aa1e9a74076e6679b07b991 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Mon, 3 Mar 2014 17:28:17 +0000 Subject: [PATCH] Allow reverse-proxy to be set via explicit handler git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1573626 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/mod/mod_proxy.xml | 17 +++++++++++++++++ modules/proxy/mod_proxy.c | 19 ++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index d0adb3a3ae..e7b5a9fd3a 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 329e805c06..1c6716b8bb 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"))) {