mirror of
https://github.com/apache/httpd.git
synced 2025-08-08 15:02:10 +03:00
Allow SetHandler+UDS+fcgi to take advantage of dedicated workers including
opting in to connection reuse and other proxy options (max=, etc). adds 'enablereuse' proxyoption and a minor MMN bump to share proxy_desocketfy outside of mod_proxy.c, which is required to match workers to URLs. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1647009 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -1567,6 +1567,8 @@ PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
url = ap_proxy_de_socketfy(p, url);
|
||||
|
||||
c = ap_strchr_c(url, ':');
|
||||
if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') {
|
||||
return NULL;
|
||||
@@ -1969,6 +1971,40 @@ static int ap_proxy_retry_worker(const char *proxy_function, proxy_worker *worke
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* In the case of the reverse proxy, we need to see if we
|
||||
* were passed a UDS url (eg: from mod_proxy) and adjust uds_path
|
||||
* as required.
|
||||
*/
|
||||
static void fix_uds_filename(request_rec *r, char **url)
|
||||
{
|
||||
char *ptr, *ptr2;
|
||||
if (!r || !r->filename) return;
|
||||
|
||||
if (!strncmp(r->filename, "proxy:", 6) &&
|
||||
(ptr2 = ap_strcasestr(r->filename, "unix:")) &&
|
||||
(ptr = ap_strchr(ptr2, '|'))) {
|
||||
apr_uri_t urisock;
|
||||
apr_status_t rv;
|
||||
*ptr = '\0';
|
||||
rv = apr_uri_parse(r->pool, ptr2, &urisock);
|
||||
if (rv == APR_SUCCESS) {
|
||||
char *rurl = ptr+1;
|
||||
char *sockpath = ap_runtime_dir_relative(r->pool, urisock.path);
|
||||
apr_table_setn(r->notes, "uds_path", sockpath);
|
||||
*url = apr_pstrdup(r->pool, rurl); /* so we get the scheme for the uds */
|
||||
/* r->filename starts w/ "proxy:", so add after that */
|
||||
memmove(r->filename+6, rurl, strlen(rurl)+1);
|
||||
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
|
||||
"*: rewrite of url due to UDS(%s): %s (%s)",
|
||||
sockpath, *url, r->filename);
|
||||
}
|
||||
else {
|
||||
*ptr = '|';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
||||
proxy_balancer **balancer,
|
||||
request_rec *r,
|
||||
@@ -1983,8 +2019,8 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
||||
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
|
||||
"%s: found worker %s for %s",
|
||||
(*worker)->s->scheme, (*worker)->s->name, *url);
|
||||
|
||||
*balancer = NULL;
|
||||
fix_uds_filename(r, url);
|
||||
access_status = OK;
|
||||
}
|
||||
else if (r->proxyreq == PROXYREQ_PROXY) {
|
||||
@@ -2004,8 +2040,6 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
||||
}
|
||||
else if (r->proxyreq == PROXYREQ_REVERSE) {
|
||||
if (conf->reverse) {
|
||||
char *ptr;
|
||||
char *ptr2;
|
||||
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
|
||||
"*: using default reverse proxy worker for %s (no keepalive)", *url);
|
||||
*balancer = NULL;
|
||||
@@ -2017,33 +2051,7 @@ PROXY_DECLARE(int) ap_proxy_pre_request(proxy_worker **worker,
|
||||
* regarding the Connection header in the request.
|
||||
*/
|
||||
apr_table_setn(r->subprocess_env, "proxy-nokeepalive", "1");
|
||||
/*
|
||||
* In the case of the generic reverse proxy, we need to see if we
|
||||
* were passed a UDS url (eg: from mod_proxy) and adjust uds_path
|
||||
* as required.
|
||||
*/
|
||||
if (!strncmp(r->filename, "proxy:", 6) &&
|
||||
(ptr2 = ap_strcasestr(r->filename, "unix:")) &&
|
||||
(ptr = ap_strchr(ptr2, '|'))) {
|
||||
apr_uri_t urisock;
|
||||
apr_status_t rv;
|
||||
*ptr = '\0';
|
||||
rv = apr_uri_parse(r->pool, ptr2, &urisock);
|
||||
if (rv == APR_SUCCESS) {
|
||||
char *rurl = ptr+1;
|
||||
char *sockpath = ap_runtime_dir_relative(r->pool, urisock.path);
|
||||
apr_table_setn(r->notes, "uds_path", sockpath);
|
||||
*url = apr_pstrdup(r->pool, rurl); /* so we get the scheme for the uds */
|
||||
/* r->filename starts w/ "proxy:", so add after that */
|
||||
memmove(r->filename+6, rurl, strlen(rurl)+1);
|
||||
ap_log_rerror(APLOG_MARK, APLOG_TRACE2, 0, r,
|
||||
"*: rewrite of url due to UDS(%s): %s (%s)",
|
||||
sockpath, *url, r->filename);
|
||||
}
|
||||
else {
|
||||
*ptr = '|';
|
||||
}
|
||||
}
|
||||
fix_uds_filename(r, url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user