From: Yann Ylavic Date: Fri, 22 Mar 2019 09:53:29 +0000 (+0000) Subject: mod_proxy: follow up to r1836588: configurable Proxy100Continue. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0848891b92604bbd5aad6823ae406ae348e7ec06;p=apache mod_proxy: follow up to r1836588: configurable Proxy100Continue. Add Proxy100Continue directive to allow for 100-continue forwarding opt-out. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1856036 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/docs/manual/mod/mod_proxy.xml b/docs/manual/mod/mod_proxy.xml index 64c27c9a2a..622a7c85f2 100644 --- a/docs/manual/mod/mod_proxy.xml +++ b/docs/manual/mod/mod_proxy.xml @@ -2128,6 +2128,29 @@ header for proxied requests + +Proxy100Continue +Forward 100-continue expectation to the origin server +Proxy100Continue Off|On +Proxy100Continue On +server config +virtual host +directory + +Available in version 2.4.39 and later + + +

This directive determines whether the proxy should forward 100-continue + Expect:ation to the origin server and thus let it decide when/if + the HTTP request body should be read, or when Off the proxy + should generate 100 Continue intermediate response by itself before + forwarding the request body.

+ Effectiveness +

This option is of use only for HTTP proxying, as handled by mod_proxy_http.

+
+
+
+ ProxySourceAddress Set local IP address for outgoing proxy connections diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 5a479c075e..8f9cab17af 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -612,6 +612,7 @@ * 20191203.1 (2.5.1-dev) Axe bucket number from struct process_score * 20191203.2 (2.5.1-dev) Add ap_no2slash_ex() and merge_slashes to * core_server_conf. + * 20191203.3 (2.5.1-dev) Add forward_100_continue{,_set} to proxy_dir_conf */ #define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */ @@ -619,7 +620,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20191203 #endif -#define MODULE_MAGIC_NUMBER_MINOR 2 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 3 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/modules/proxy/mod_proxy.c b/modules/proxy/mod_proxy.c index d754f7b09e..251afbf3a2 100644 --- a/modules/proxy/mod_proxy.c +++ b/modules/proxy/mod_proxy.c @@ -1579,6 +1579,8 @@ static void *create_proxy_dir_config(apr_pool_t *p, char *dummy) new->error_override_set = 0; new->add_forwarded_headers = 1; new->add_forwarded_headers_set = 0; + new->forward_100_continue = 1; + new->forward_100_continue_set = 0; return (void *) new; } @@ -1615,6 +1617,11 @@ static void *merge_proxy_dir_config(apr_pool_t *p, void *basev, void *addv) : add->add_forwarded_headers; new->add_forwarded_headers_set = add->add_forwarded_headers_set || base->add_forwarded_headers_set; + new->forward_100_continue = + (add->forward_100_continue_set == 0) ? base->forward_100_continue + : add->forward_100_continue; + new->forward_100_continue_set = add->forward_100_continue_set + || base->forward_100_continue_set; return new; } @@ -2130,6 +2137,14 @@ static const char * conf->preserve_host_set = 1; return NULL; } +static const char * + forward_100_continue(cmd_parms *parms, void *dconf, int flag) +{ + proxy_dir_conf *conf = dconf; + conf->forward_100_continue = flag; + conf->forward_100_continue_set = 1; + return NULL; +} static const char * set_recv_buffer_size(cmd_parms *parms, void *dummy, const char *arg) @@ -2717,6 +2732,9 @@ static const command_rec proxy_cmds[] = "Configure local source IP used for request forward"), AP_INIT_FLAG("ProxyAddHeaders", add_proxy_http_headers, NULL, RSRC_CONF|ACCESS_CONF, "on if X-Forwarded-* headers should be added or completed"), + AP_INIT_FLAG("Proxy100Continue", forward_100_continue, NULL, RSRC_CONF|ACCESS_CONF, + "on if 100-Continue should be forwarded to the origin server, off if the " + "proxy should handle it by itself"), {NULL} }; diff --git a/modules/proxy/mod_proxy.h b/modules/proxy/mod_proxy.h index 152a79103e..e94f64c533 100644 --- a/modules/proxy/mod_proxy.h +++ b/modules/proxy/mod_proxy.h @@ -240,6 +240,8 @@ typedef struct { /** Named back references */ apr_array_header_t *refs; + unsigned int forward_100_continue:1; + unsigned int forward_100_continue_set:1; } proxy_dir_conf; /* if we interpolate env vars per-request, we'll need a per-request diff --git a/modules/proxy/mod_proxy_http.c b/modules/proxy/mod_proxy_http.c index 8bd5e2d5e2..4dfdfd1672 100644 --- a/modules/proxy/mod_proxy_http.c +++ b/modules/proxy/mod_proxy_http.c @@ -1947,6 +1947,7 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker, proxy_conn_rec *backend = NULL; int is_ssl = 0; conn_rec *c = r->connection; + proxy_dir_conf *dconf; int retry = 0; char *locurl = url; int toclose = 0; @@ -2007,8 +2008,11 @@ static int proxy_http_handler(request_rec *r, proxy_worker *worker, req->bucket_alloc = c->bucket_alloc; req->rb_method = RB_INIT; + dconf = ap_get_module_config(r->per_dir_config, &proxy_module); + /* Should we handle end-to-end or ping 100-continue? */ - if (r->expecting_100 || PROXY_DO_100_CONTINUE(worker, r)) { + if ((r->expecting_100 && dconf->forward_100_continue) + || PROXY_DO_100_CONTINUE(worker, r)) { /* We need to reset r->expecting_100 or prefetching will cause * ap_http_filter() to send "100 Continue" response by itself. So * we'll use req->expecting_100 in mod_proxy_http to determine whether