Skip to content

Commit

Permalink
mod_proxy: Allow for empty UDS URL hostname in ProxyPass workers too.
Browse files Browse the repository at this point in the history
Using "unix:/udspath|scheme:" or "unix:/udspath|scheme://" for a ProxyPass URL
does not work currently, while it works for SetHandler "proxy:unix:...".



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1919533 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
ylavic committed Jul 26, 2024
1 parent d80ec5f commit 9b3659b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions modules/proxy/mod_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1948,16 +1948,19 @@ PROXY_DECLARE(const char *) ap_proxy_de_socketfy(apr_pool_t *p, const char *url)
const char *ret, *c;

ret = ptr + 1;
/* special case: "unix:....|scheme:" is OK, expand
* to "unix:....|scheme://localhost"
* */
/* special cases: "unix:...|scheme:" ind "unix:...|scheme://" are OK,
* expand to "unix:....|scheme://localhost"
*/
c = ap_strchr_c(ret, ':');
if (c == NULL) {
return NULL;
}
if (c[1] == '\0') {
return apr_pstrcat(p, ret, "//localhost", NULL);
}
else if (c[1] == '/' && c[2] == '/' && !c[3]) {
return apr_pstrcat(p, ret, "localhost", NULL);
}
else {
return ret;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/proxy/proxy_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker_ex(apr_pool_t *p,
&& (ptr = ap_strchr_c(url + 5, '|'))) {
rv = apr_uri_parse(p, apr_pstrmemdup(p, url, ptr - url), &uri);
if (rv == APR_SUCCESS) {
sockpath = ap_runtime_dir_relative(p, uri.path);;
sockpath = ap_runtime_dir_relative(p, uri.path);
ptr++; /* so we get the scheme for the uds */
}
else {
Expand Down Expand Up @@ -2038,7 +2038,7 @@ PROXY_DECLARE(char *) ap_proxy_define_worker_ex(apr_pool_t *p,
if (!uri.scheme) {
return apr_pstrcat(p, "URL must be absolute!: ", url, NULL);
}
if (!uri.hostname) {
if (!uri.hostname || !*uri.hostname) {
if (sockpath) {
/* allow for unix:/path|http: */
uri.hostname = "localhost";
Expand Down

0 comments on commit 9b3659b

Please sign in to comment.