+mod_proxy changes for httpd 2.0.26-dev
+ *) Add New option 'HTTPProxyOverrideReturnedErrors'. By Turning the
+ Flag on, you will mask the error pages returned by the proxied
+ server, and will it will be handled as if your server generated
+ the error. This change was put in so that a 404 on a included
+ r-proxied component will act in the same manner as a 404 on a
+ included file. [Ian Holsman <ianh@cnet.com>]
+
mod_proxy changes for httpd 2.0.25-dev
*) Split proxy: space using <Proxy[Match] > directive blocks from
ps->recv_buffer_size_set = 0;
ps->maxfwd = DEFAULT_MAX_FORWARDS;
ps->maxfwd_set = 0;
-
+ ps->HTTPOverrideErrors=0;
return ps;
}
psf->req_set = 1;
return NULL;
}
+static const char *
+ set_http_proxy_override_error(cmd_parms *parms, void *dummy, int flag)
+{
+ proxy_server_conf *psf =
+ ap_get_module_config(parms->server->module_config, &proxy_module);
+
+ psf->HTTPOverrideErrors = flag;
+ return NULL;
+}
static const char *
set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg)
"A list of ports which CONNECT may connect to"),
AP_INIT_TAKE1("ProxyVia", set_via_opt, NULL, RSRC_CONF,
"Configure Via: proxy header header to one of: on | off | block | full"),
+ AP_INIT_FLAG("HTTPProxyOverrideReturnedErrors", set_http_proxy_override_error, NULL, RSRC_CONF,
+ "use our error handling pages instead of the servers we are proxying"),
{NULL}
};
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
"proxy: start body send");
+ /*
+ * if we are overriding the errors, we cant put the content of the
+ * page into the brigade
+ */
+ if ( (conf->HTTPOverrideErrors ==0) || r->status < 400 ) {
/* read the body, pass it to the output filters */
- while (ap_get_brigade(rp->input_filters, bb, AP_MODE_NONBLOCKING, &readbytes) == APR_SUCCESS) {
+ while (ap_get_brigade(rp->input_filters,
+ bb,
+ AP_MODE_NONBLOCKING,
+ &readbytes) == APR_SUCCESS) {
#if DEBUGGING
- ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
- r->server, "proxy (PID %d): readbytes: %#x",
- getpid(), readbytes);
+ ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0,
+ r->server, "proxy (PID %d): readbytes: %#x",
+ getpid(), readbytes);
#endif
- if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {
- ap_pass_brigade(r->output_filters, bb);
- break;
- }
- if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS) {
- /* Ack! Phbtt! Die! User aborted! */
- p_conn->close = 1; /* this causes socket close below */
- break;
+ if (APR_BUCKET_IS_EOS(APR_BRIGADE_LAST(bb))) {
+ ap_pass_brigade(r->output_filters, bb);
+ break;
+ }
+ if (ap_pass_brigade(r->output_filters, bb) != APR_SUCCESS) {
+ /* Ack! Phbtt! Die! User aborted! */
+ p_conn->close = 1; /* this causes socket close below */
+ break;
+ }
+ apr_brigade_cleanup(bb);
}
- apr_brigade_cleanup(bb);
}
ap_log_error(APLOG_MARK, APLOG_DEBUG|APLOG_NOERRNO, 0, r->server,
"proxy: end body send");
"proxy: header only");
}
}
- return OK;
+
+ if ( conf->HTTPOverrideErrors )
+ return r->status;
+ else
+ return OK;
}
static
status = ap_proxy_http_process_response(p, r, p_conn, origin, backend, conf,
bb, server_portstr);
if ( status != OK ) {
+ /* clean up even if there is an error */
+ ap_proxy_http_cleanup(r, p_conn, backend);
return status;
}