-*- coding: utf-8 -*-
Changes with Apache 2.5.1
+ *) mod_proxy: Provide an RFC1035 compliant version of the hostname in the
+ proxy_worker_shared structure. PR62085 [Graham Leggett]
+
*) mod_proxy: Worker schemes and hostnames which are too large are no
longer fatal errors; it is logged and the truncated values are stored.
for (i = 0; i < balancer->workers->nelts; i++) {
worker = &APR_ARRAY_IDX(balancer->workers, i, proxy_worker *);
- server = apr_hash_get(servers, (*worker)->s->hostname, APR_HASH_KEY_STRING);
+ server = apr_hash_get(servers, (*worker)->s->hostname_ex, APR_HASH_KEY_STRING);
if (!server) {
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, rv, r, APLOGNO(01214)
char fbuf[50];
if (!(flags & AP_STATUS_SHORT)) {
ap_rvputs(r, "<tr>\n<td>", (*worker)->s->scheme, "</td>", NULL);
- ap_rvputs(r, "<td>", (*worker)->s->hostname, "</td><td>", NULL);
+ ap_rvputs(r, "<td>", (*worker)->s->hostname_ex, "</td><td>", NULL);
ap_rvputs(r, ap_proxy_parse_wstatus(r->pool, *worker), NULL);
ap_rvputs(r, "</td><td>", (*worker)->s->route, NULL);
ap_rvputs(r, "</td><td>", (*worker)->s->redirect, NULL);
ap_proxy_define_worker(p, &forward, NULL, NULL, "http://www.apache.org", 0);
conf->forward = forward;
PROXY_STRNCPY(conf->forward->s->name, "proxy:forward");
- PROXY_STRNCPY(conf->forward->s->hostname, "*");
+ PROXY_STRNCPY(conf->forward->s->hostname, "*"); /* for compatibility */
+ PROXY_STRNCPY(conf->forward->s->hostname_ex, "*");
PROXY_STRNCPY(conf->forward->s->scheme, "*");
conf->forward->hash.def = conf->forward->s->hash.def =
ap_proxy_hashfunc(conf->forward->s->name, PROXY_HASHFUNC_DEFAULT);
if (!reverse) {
ap_proxy_define_worker(p, &reverse, NULL, NULL, "http://www.apache.org", 0);
PROXY_STRNCPY(reverse->s->name, "proxy:reverse");
- PROXY_STRNCPY(reverse->s->hostname, "*");
+ PROXY_STRNCPY(reverse->s->hostname, "*"); /* for compatibility */
+ PROXY_STRNCPY(reverse->s->hostname_ex, "*");
PROXY_STRNCPY(reverse->s->scheme, "*");
reverse->hash.def = reverse->s->hash.def =
ap_proxy_hashfunc(reverse->s->name, PROXY_HASHFUNC_DEFAULT);
#define PROXY_BALANCER_MAX_STICKY_SIZE 64
#define PROXY_WORKER_MAX_SECRET_SIZE 64
+#define PROXY_RFC1035_HOSTNAME_SIZE 256
+
/* RFC-1035 mentions limits of 255 for host-names and 253 for domain-names,
* dotted together(?) this would fit the below size (+ trailing NUL).
*/
typedef struct {
char name[PROXY_WORKER_MAX_NAME_SIZE];
char scheme[PROXY_WORKER_MAX_SCHEME_SIZE]; /* scheme to use ajp|http|https */
- char hostname[PROXY_WORKER_MAX_HOSTNAME_SIZE]; /* remote backend address */
+ char hostname[PROXY_WORKER_MAX_HOSTNAME_SIZE]; /* remote backend address (deprecated, use hostname_ex below) */
char route[PROXY_WORKER_MAX_ROUTE_SIZE]; /* balancing route */
char redirect[PROXY_WORKER_MAX_ROUTE_SIZE]; /* temporary balancing redirection route */
char flusher[PROXY_WORKER_MAX_SCHEME_SIZE]; /* flush provider used by mod_proxy_fdpass */
unsigned int is_name_matchable:1;
char secret[PROXY_WORKER_MAX_SECRET_SIZE]; /* authentication secret (e.g. AJP13) */
char upgrade[PROXY_WORKER_MAX_SCHEME_SIZE];/* upgrade protocol used by mod_proxy_wstunnel */
+ char hostname_ex[PROXY_RFC1035_HOSTNAME_SIZE]; /* RFC1035 compliant version of the remote backend address */
} proxy_worker_shared;
#define ALIGNED_PROXY_WORKER_SHARED_SIZE (APR_ALIGN_DEFAULT(sizeof(proxy_worker_shared)))
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(00868)
"request failed to %pI (%s)",
conn->worker->cp->addr,
- conn->worker->s->hostname);
+ conn->worker->s->hostname_ex);
if (status == AJP_EOVERFLOW)
return HTTP_BAD_REQUEST;
else {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(00876)
"send failed to %pI (%s)",
conn->worker->cp->addr,
- conn->worker->s->hostname);
+ conn->worker->s->hostname_ex);
/*
* It is fatal when we failed to send a (part) of the request
* body.
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(00878)
"read response failed from %pI (%s)",
conn->worker->cp->addr,
- conn->worker->s->hostname);
+ conn->worker->s->hostname_ex);
/* If we had a successful cping/cpong and then a timeout
* we assume it is a request that cause a back-end timeout,
ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r, APLOGNO(00892)
"got response from %pI (%s)",
conn->worker->cp->addr,
- conn->worker->s->hostname);
+ conn->worker->s->hostname_ex);
if (conf->error_override && ap_is_HTTP_ERROR(r->status)) {
/* clear r->status for override error, otherwise ErrorDocument
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(00893)
"dialog to %pI (%s) failed",
conn->worker->cp->addr,
- conn->worker->s->hostname);
+ conn->worker->s->hostname_ex);
/*
* If we already send data, signal a broken backend connection
* upwards in the chain.
backend->close = 1;
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r, APLOGNO(00897)
"cping/cpong failed to %pI (%s)",
- worker->cp->addr, worker->s->hostname);
+ worker->cp->addr, worker->s->hostname_ex);
status = HTTP_SERVICE_UNAVAILABLE;
retry++;
continue;
(*worker)->s->status &= ~PROXY_WORKER_IN_ERROR;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(01165)
"%s: Forcing recovery for worker (%s)",
- balancer->s->name, (*worker)->s->hostname);
+ balancer->s->name, (*worker)->s->hostname_ex);
}
}
}
"</httpd:name>\n", NULL);
ap_rvputs(r, " <httpd:scheme>", worker->s->scheme,
"</httpd:scheme>\n", NULL);
- ap_rvputs(r, " <httpd:hostname>", worker->s->hostname,
+ ap_rvputs(r, " <httpd:hostname>", worker->s->hostname_ex,
"</httpd:hostname>\n", NULL);
ap_rprintf(r, " <httpd:loadfactor>%.2f</httpd:loadfactor>\n",
(float)(worker->s->lbfactor)/100.0);
"OPTIONS * HTTP/1.0\r\n"
"Host: %s:%d\r\n"
"\r\n",
- hc->s->hostname, (int)hc->s->port);
+ hc->s->hostname_ex, (int)hc->s->port);
break;
case HEAD:
(wctx->path ? wctx->path : ""),
(wctx->path && *hc->s->hcuri ? "/" : "" ),
(*hc->s->hcuri ? hc->s->hcuri : ""),
- hc->s->hostname, (int)hc->s->port);
+ hc->s->hostname_ex, (int)hc->s->port);
break;
default:
: ap_proxy_port_of_scheme(worker->s->scheme));
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ctx->s, APLOGNO(03248)
"Creating hc worker %pp for %s://%s:%d",
- worker, worker->s->scheme, worker->s->hostname,
+ worker, worker->s->scheme, worker->s->hostname_ex,
(int)port);
ap_proxy_define_worker(ctx->p, &hc, NULL, NULL, worker->s->name, 0);
apr_snprintf(hc->s->name, sizeof hc->s->name, "%pp", worker);
- PROXY_STRNCPY(hc->s->hostname, worker->s->hostname);
+ PROXY_STRNCPY(hc->s->hostname, worker->s->hostname); /* for compatibility */
+ PROXY_STRNCPY(hc->s->hostname_ex, worker->s->hostname_ex);
PROXY_STRNCPY(hc->s->scheme, worker->s->scheme);
PROXY_STRNCPY(hc->s->hcuri, worker->s->hcuri);
PROXY_STRNCPY(hc->s->hcexpr, worker->s->hcexpr);
: ap_proxy_port_of_scheme(worker->s->scheme));
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ctx->s, APLOGNO(03311)
"Updating hc worker %pp for %s://%s:%d",
- worker, worker->s->scheme, worker->s->hostname,
+ worker, worker->s->scheme, worker->s->hostname_ex,
(int)port);
hc->s->method = worker->s->method;
create_hcheck_req(wctx, hc, ctx->p);
*addr = worker->cp->addr;
}
else {
- rv = apr_sockaddr_info_get(addr, worker->s->hostname,
+ rv = apr_sockaddr_info_get(addr, worker->s->hostname_ex,
APR_UNSPEC, worker->s->port, 0, p);
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ctx->s, APLOGNO(03249)
"DNS lookup failure for: %s:%d",
- worker->s->hostname, (int)worker->s->port);
+ worker->s->hostname_ex, (int)worker->s->port);
}
}
return (rv == APR_SUCCESS ? OK : !OK);
status = ap_proxy_acquire_connection(proxy_function, backend, hc, ctx->s);
if (status == OK) {
(*backend)->addr = hc->cp->addr;
- (*backend)->hostname = hc->s->hostname;
+ (*backend)->hostname = hc->s->hostname_ex;
if (strcmp(hc->s->scheme, "https") == 0) {
if (!ap_proxy_ssl_enable(NULL)) {
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, ctx->s, APLOGNO(03252)
backend->close = 1;
ap_log_rerror(APLOG_MARK, APLOG_INFO, status, r, APLOGNO(01115)
"HTTP: 100-Continue failed to %pI (%s)",
- worker->cp->addr, worker->s->hostname);
+ worker->cp->addr, worker->s->hostname_ex);
retry++;
continue;
} else {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, ap_server_conf, APLOGNO(010118)
"Alert! worker hostname (%s) too long; truncated to: %s", uri.hostname, wshared->hostname);
}
+ if (PROXY_STRNCPY(wshared->hostname_ex, uri.hostname) != APR_SUCCESS) {
+ return apr_psprintf(p, "worker hostname (%s) too long", uri.hostname);
+ }
wshared->flush_packets = flush_off;
wshared->flush_wait = PROXY_FLUSH_WAIT;
wshared->is_address_reusable = 1;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00930)
"initialized pool in child %" APR_PID_T_FMT " for (%s) min=%d max=%d smax=%d",
- getpid(), worker->s->hostname, worker->s->min,
+ getpid(), worker->s->hostname_ex, worker->s->min,
worker->s->hmax, worker->s->smax);
/* Set the acquire timeout */
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00931)
"initialized single connection worker in child %" APR_PID_T_FMT " for (%s)",
- getpid(), worker->s->hostname);
+ getpid(), worker->s->hostname_ex);
}
apr_global_mutex_unlock(proxy_mutex);
if (PROXY_WORKER_IS(worker, PROXY_WORKER_STOPPED)) {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(3305)
"%s: Won't retry worker (%s): stopped",
- proxy_function, worker->s->hostname);
+ proxy_function, worker->s->hostname_ex);
return DECLINED;
}
if ((worker->s->status & PROXY_WORKER_IGNORE_ERRORS)
worker->s->status &= ~PROXY_WORKER_IN_ERROR;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00932)
"%s: worker for (%s) has been marked for retry",
- proxy_function, worker->s->hostname);
+ proxy_function, worker->s->hostname_ex);
return OK;
}
else {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00933)
"%s: too soon to retry worker for (%s)",
- proxy_function, worker->s->hostname);
+ proxy_function, worker->s->hostname_ex);
return DECLINED;
}
}
if (!PROXY_WORKER_IS_USABLE(worker)) {
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00940)
"%s: disabled connection for (%s)",
- proxy_function, worker->s->hostname);
+ proxy_function, worker->s->hostname_ex);
return HTTP_SERVICE_UNAVAILABLE;
}
}
if (rv != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_ERR, rv, s, APLOGNO(00941)
"%s: failed to acquire connection for (%s)",
- proxy_function, worker->s->hostname);
+ proxy_function, worker->s->hostname_ex);
return HTTP_SERVICE_UNAVAILABLE;
}
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00942)
"%s: has acquired connection for (%s)",
- proxy_function, worker->s->hostname);
+ proxy_function, worker->s->hostname_ex);
(*conn)->worker = worker;
(*conn)->close = 0;
{
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, APLOGNO(00943)
"%s: has released connection for (%s)",
- proxy_function, conn->worker->s->hostname);
+ proxy_function, conn->worker->s->hostname_ex);
connection_cleanup(conn);
return OK;
"%s: error creating Unix domain socket for "
"target %s",
proxy_function,
- worker->s->hostname);
+ worker->s->hostname_ex);
break;
}
conn->connection = NULL;
"%s (%s) failed",
proxy_function,
conn->uds_path,
- worker->s->hostname);
+ worker->s->hostname_ex);
break;
}
"%s (%s)",
proxy_function,
conn->uds_path,
- worker->s->hostname);
+ worker->s->hostname_ex);
}
else
#endif
"target %s",
proxy_function,
backend_addr->family,
- worker->s->hostname);
+ worker->s->hostname_ex);
/*
* this could be an IPv6 address from the DNS but the
* local machine won't give us an IPv6 socket; hopefully the
}
ap_log_error(APLOG_MARK, APLOG_TRACE2, 0, s,
"%s: fam %d socket created to connect to %s",
- proxy_function, backend_addr->family, worker->s->hostname);
+ proxy_function, backend_addr->family, worker->s->hostname_ex);
if (conf->source_address_set) {
local_addr = apr_pmemdup(conn->scpool, conf->source_address,
"%s: attempt to connect to %pI (%s) failed",
proxy_function,
backend_addr,
- worker->s->hostname);
+ worker->s->hostname_ex);
backend_addr = backend_addr->next;
continue;
}
"%s: connection established with %pI (%s)",
proxy_function,
backend_addr,
- worker->s->hostname);
+ worker->s->hostname_ex);
}
/* Set a timeout on the socket */
"via http CONNECT through %pI (%s) failed",
proxy_function,
forward->target_host, forward->target_port,
- backend_addr, worker->s->hostname);
+ backend_addr, worker->s->hostname_ex);
backend_addr = backend_addr->next;
continue;
}
ap_log_error(APLOG_MARK, APLOG_ERR, 0, s, APLOGNO(00959)
"ap_proxy_connect_backend disabling worker for (%s) for %"
APR_TIME_T_FMT "s",
- worker->s->hostname, apr_time_sec(worker->s->retry));
+ worker->s->hostname_ex, apr_time_sec(worker->s->retry));
}
}
else {