Skip to content

Instantly share code, notes, and snippets.

@Mons
Created July 19, 2017 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mons/1b64afd4b5fbb64fb9f4baffe4d61d2c to your computer and use it in GitHub Desktop.
Save Mons/1b64afd4b5fbb64fb9f4baffe4d61d2c to your computer and use it in GitHub Desktop.
Disable local 100 continue response, proxy it from upstream
diff -r -u nginx-1.10.3.orig/src/http/ngx_http_core_module.c nginx-1.10.3/src/http/ngx_http_core_module.c
--- nginx-1.10.3.orig/src/http/ngx_http_core_module.c 2017-01-31 18:01:11.000000000 +0300
+++ nginx-1.10.3/src/http/ngx_http_core_module.c 2017-02-13 15:37:11.505036520 +0300
@@ -626,6 +626,13 @@
offsetof(ngx_http_core_loc_conf_t, etag),
NULL },
+ { ngx_string("proxy_100_continue"),
+ NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
+ ngx_conf_set_flag_slot,
+ NGX_HTTP_LOC_CONF_OFFSET,
+ offsetof(ngx_http_core_loc_conf_t, proxy_100_continue),
+ NULL },
+
{ ngx_string("error_page"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
|NGX_CONF_2MORE,
@@ -3647,6 +3654,7 @@
clcf->server_tokens = NGX_CONF_UNSET;
clcf->chunked_transfer_encoding = NGX_CONF_UNSET;
clcf->etag = NGX_CONF_UNSET;
+ clcf->proxy_100_continue = NGX_CONF_UNSET;
clcf->types_hash_max_size = NGX_CONF_UNSET_UINT;
clcf->types_hash_bucket_size = NGX_CONF_UNSET_UINT;
@@ -3914,6 +3922,7 @@
ngx_conf_merge_value(conf->chunked_transfer_encoding,
prev->chunked_transfer_encoding, 1);
ngx_conf_merge_value(conf->etag, prev->etag, 1);
+ ngx_conf_merge_value(conf->proxy_100_continue, prev->proxy_100_continue, 0);
ngx_conf_merge_ptr_value(conf->open_file_cache,
prev->open_file_cache, NULL);
diff -r -u nginx-1.10.3.orig/src/http/ngx_http_core_module.h nginx-1.10.3/src/http/ngx_http_core_module.h
--- nginx-1.10.3.orig/src/http/ngx_http_core_module.h 2017-01-31 18:01:11.000000000 +0300
+++ nginx-1.10.3/src/http/ngx_http_core_module.h 2017-02-13 15:35:13.468039254 +0300
@@ -418,6 +418,7 @@
ngx_flag_t server_tokens; /* server_tokens */
ngx_flag_t chunked_transfer_encoding; /* chunked_transfer_encoding */
ngx_flag_t etag; /* etag */
+ ngx_flag_t proxy_100_continue; /* proxy_100_continue to upstream */
#if (NGX_HTTP_GZIP)
ngx_flag_t gzip_vary; /* gzip_vary */
diff -r -u nginx-1.10.3.orig/src/http/ngx_http_request_body.c nginx-1.10.3/src/http/ngx_http_request_body.c
--- nginx-1.10.3.orig/src/http/ngx_http_request_body.c 2017-01-31 18:01:11.000000000 +0300
+++ nginx-1.10.3/src/http/ngx_http_request_body.c 2017-02-13 15:38:17.910034981 +0300
@@ -53,10 +53,18 @@
}
#endif
- if (ngx_http_test_expect(r) != NGX_OK) {
- rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
- goto done;
- }
+ clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
+
+ if (clcf->proxy_100_continue) {
+
+ r->expect_tested = 1;
+
+ } else {
+ if (ngx_http_test_expect(r) != NGX_OK) {
+ rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
+ goto done;
+ }
+ }
rb = ngx_pcalloc(r->pool, sizeof(ngx_http_request_body_t));
if (rb == NULL) {
@@ -155,8 +163,6 @@
goto done;
}
- clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
-
size = clcf->client_body_buffer_size;
size += size >> 2;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment