From 9b6fb3d615aeeffe51f33ce474dc71b6a850a524 Mon Sep 17 00:00:00 2001 From: Jim Jagielski Date: Tue, 15 Oct 2013 15:38:09 +0000 Subject: [PATCH] Standardize on: unix:/path/to/socket|scheme://ignored for ProxyPass UDS. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1532394 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/mod/mod_proxy.xml | 9 +++++---- modules/proxy/proxy_util.c | 15 ++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index fce53667e0..293aab504e 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -823,13 +823,14 @@ expressions ProxyPass.

Support for using a Unix Domain Socket is available by using a target - which appends |sock:/path/lis.sock. For example, to proxy + which prepends unix:/path/lis.sock|. For example, to proxy HTTP and target the UDS at /home/www/socket you would use - http://localhost/|sock:/home/www.socket.

+ unix:/home/www.socket|http://localhost/.

Note: When using Unix Domain Sockets, the hostname and path - associated with the 1st URL (http://localhost/ in the above - example) is ignored; the path associated with the sock: + associated with the 2nd URL (http://localhost/ in the above + example) is ignored; only the scheme is significant. + The path associated with the unix: URL is DefaultRuntimeDir aware.

Suppose the local server has address http://example.com/; diff --git a/modules/proxy/proxy_util.c b/modules/proxy/proxy_util.c index a02af850e8..1b7fbd3377 100644 --- a/modules/proxy/proxy_util.c +++ b/modules/proxy/proxy_util.c @@ -1508,7 +1508,7 @@ PROXY_DECLARE(char *) ap_proxy_worker_name(apr_pool_t *p, if (rv != APR_SUCCESS) { return apr_pstrcat(pool, worker->s->name, "|", NULL); } - return apr_pstrcat(pool, uri.scheme, "://localhost/|sock:", uri.path, NULL); + return apr_pstrcat(pool, "unix:", uri.path, "|", uri.scheme, ":", NULL); } PROXY_DECLARE(proxy_worker *) ap_proxy_get_worker(apr_pool_t *p, @@ -1610,15 +1610,16 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p, char *ptr, *sockpath = NULL; /* Look to see if we are using UDS: - require format: http://ignored/ignored|sock:/path/foo/bar.sock + require format: unix:/path/foo/bar.sock|http: This results in talking http to the socket at /path/foo/bar.sock */ ptr = ap_strchr((char *)url, '|'); if (ptr) { *ptr = '\0'; - rv = apr_uri_parse(p, ptr+1, &urisock); - if (rv == APR_SUCCESS && !strcasecmp(urisock.scheme, "sock")) { + rv = apr_uri_parse(p, url, &urisock); + if (rv == APR_SUCCESS && !strcasecmp(urisock.scheme, "unix")) { sockpath = urisock.path; + url = ptr+1; /* so we get the scheme for the uds */ } else { *ptr = '|'; @@ -1627,14 +1628,14 @@ PROXY_DECLARE(char *) ap_proxy_define_worker(apr_pool_t *p, rv = apr_uri_parse(p, url, &uri); if (rv != APR_SUCCESS) { - return "Unable to parse URL"; + return apr_pstrcat(p, "Unable to parse URL: ", url, NULL); } if (!uri.scheme) { - return "URL must be absolute!"; + return apr_pstrcat(p, "URL must be absolute!: ", url, NULL); } /* allow for http:|sock:/path */ if (!uri.hostname && !sockpath) { - return "URL must be absolute!"; + return apr_pstrcat(p, "URL must be absolute!: ", url, NULL);; } if (sockpath) { -- 2.40.0