1
0
mirror of https://github.com/apache/httpd.git synced 2025-08-08 15:02:10 +03:00

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
This commit is contained in:
Jim Jagielski
2014-03-03 17:28:17 +00:00
parent fcdb670c36
commit cd304f4964
2 changed files with 35 additions and 1 deletions

View File

@@ -171,6 +171,23 @@ ProxyVia On
</example> </example>
</section> <!-- /examples --> </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> <section id="workers"><title>Workers</title>
<p>The proxy manages the configuration of origin servers and their <p>The proxy manages the configuration of origin servers and their

View File

@@ -927,8 +927,25 @@ static int proxy_handler(request_rec *r)
struct dirconn_entry *list = (struct dirconn_entry *)conf->dirconn->elts; struct dirconn_entry *list = (struct dirconn_entry *)conf->dirconn->elts;
/* is this for us? */ /* is this for us? */
if (!r->proxyreq || !r->filename || strncmp(r->filename, "proxy:", 6) != 0) if (!r->filename) {
return DECLINED; 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 */ /* handle max-forwards / OPTIONS / TRACE */
if ((str = apr_table_get(r->headers_in, "Max-Forwards"))) { if ((str = apr_table_get(r->headers_in, "Max-Forwards"))) {