Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jfclere committed Nov 1, 2023
1 parent b45212e commit 869cb68
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions native/mod_proxy_cluster/mod_proxy_cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ static int creat_bal = CREAT_ROOT;
static int use_alias = 0; /* 1 : Compare Alias with server_name */
static int deterministic_failover = 0;
static int use_nocanon = 0;
static int return503_when_no_context = 0;

static apr_time_t lbstatus_recalc_time = apr_time_from_sec(5); /* recalcul the lbstatus based on number of request in the time interval */

Expand Down Expand Up @@ -3617,12 +3618,18 @@ static int proxy_cluster_pre_request(proxy_worker **worker,

return HTTP_SERVICE_UNAVAILABLE;
} else {
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
int loglevel = APLOG_DEBUG;
apr_status_t error_code = HTTP_NOT_FOUND;
if (return503_when_no_context) {
loglevel = APLOG_ERR;
error_code = HTTP_SERVICE_UNAVAILABLE;
}
ap_log_error(APLOG_MARK, error_code, 0, r->server,
"proxy: CLUSTER: (%s). No context for the URL",
(*balancer)->s->name
);

return HTTP_NOT_FOUND;
return error_code;
}
}
if ((*balancer)->s->sticky[0] != '\0' && runtime) {
Expand Down Expand Up @@ -3947,6 +3954,12 @@ static const char *cmd_proxy_cluster_use_nocanon(cmd_parms *parms, void *mconfig
return NULL;
}

static const char *cmd_proxy_cluster_return503_when_no_context(cmd_parms *parms, void *mconfig, int on)
{
return503_when_no_context = on;

return NULL;
}

static const command_rec proxy_cluster_cmds[] =
{
Expand Down Expand Up @@ -4007,6 +4020,14 @@ static const command_rec proxy_cluster_cmds[] =
OR_ALL,
"UseNocanon - When no ProxyPass or ProxyMatch for the URL, passes the URL path \"raw\" to the backend (Default: Off)"
),

AP_INIT_FLAG(
"Return503WhenNoContext",
cmd_proxy_cluster_return503_when_no_context,
NULL,
OR_ALL,
"Return503WhenNoContext - When ProxyPass or ProxyMatch doesn't have matching context return 503 (Default: Off)"
),
{NULL}
};

Expand Down

0 comments on commit 869cb68

Please sign in to comment.