aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/proxy
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules/proxy')
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_handler.c61
-rw-r--r--src/http/modules/proxy/ngx_http_proxy_upstream.c16
2 files changed, 62 insertions, 15 deletions
diff --git a/src/http/modules/proxy/ngx_http_proxy_handler.c b/src/http/modules/proxy/ngx_http_proxy_handler.c
index 0dba23f9b..95d565442 100644
--- a/src/http/modules/proxy/ngx_http_proxy_handler.c
+++ b/src/http/modules/proxy/ngx_http_proxy_handler.c
@@ -814,6 +814,8 @@ static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
ngx_http_proxy_loc_conf_t *prev = parent;
ngx_http_proxy_loc_conf_t *conf = child;
+ size_t size;
+
ngx_conf_merge_msec_value(conf->connect_timeout,
prev->connect_timeout, 60000);
ngx_conf_merge_msec_value(conf->send_timeout, prev->send_timeout, 30000);
@@ -823,22 +825,65 @@ static char *ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf,
ngx_conf_merge_value(conf->add_x_forwarded_for,
prev->add_x_forwarded_for, 0);
+ ngx_conf_merge_msec_value(conf->read_timeout, prev->read_timeout, 30000);
+
ngx_conf_merge_size_value(conf->header_buffer_size,
prev->header_buffer_size, 4096);
- ngx_conf_merge_msec_value(conf->read_timeout, prev->read_timeout, 30000);
ngx_conf_merge_bufs_value(conf->bufs, prev->bufs, 8, 4096);
+
+ size = conf->header_buffer_size;
+ if (size < conf->bufs.size) {
+ size = conf->bufs.size;
+ }
+
+
ngx_conf_merge_size_value(conf->busy_buffers_size,
- prev->busy_buffers_size, 8192);
+ prev->busy_buffers_size, NGX_CONF_UNSET_SIZE);
-#if 0
- if (conf->max_temp_file_size > conf->bufs.size) {
- return "\"proxy_max_temp_file\" must be greater "
- "than one of the \"proxy_buffers\"";
+ if (conf->busy_buffers_size == NGX_CONF_UNSET_SIZE) {
+ conf->busy_buffers_size = 2 * size;
+
+ } else if (conf->busy_buffers_size < size) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"proxy_busy_buffers_size\" must be equal or bigger than "
+ "maximum of the value of \"proxy_header_buffer_size\" and "
+ "one of the \"proxy_buffers\"");
+
+ return NGX_CONF_ERROR;
}
-#endif
+
ngx_conf_merge_size_value(conf->temp_file_write_size,
- prev->temp_file_write_size, 16384);
+ prev->temp_file_write_size, NGX_CONF_UNSET_SIZE);
+
+ if (conf->temp_file_write_size == NGX_CONF_UNSET_SIZE) {
+ conf->temp_file_write_size = 2 * size;
+
+ } else if (conf->temp_file_write_size < size) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"proxy_temp_file_write_size\" must be equal or bigger than "
+ "maximum of the value of \"proxy_header_buffer_size\" and "
+ "one of the \"proxy_buffers\"");
+
+ return NGX_CONF_ERROR;
+ }
+
+
+ ngx_conf_merge_size_value(conf->max_temp_file_size,
+ prev->max_temp_file_size, NGX_CONF_UNSET_SIZE);
+
+ if (conf->max_temp_file_size == NGX_CONF_UNSET_SIZE) {
+ conf->max_temp_file_size = 2 * size;
+
+ } else if (conf->max_temp_file_size < size) {
+ ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+ "\"proxy_max_temp_file_size\" must be equal or bigger than "
+ "maximum of the value of \"proxy_header_buffer_size\" and "
+ "one of the \"proxy_buffers\"");
+
+ return NGX_CONF_ERROR;
+ }
+
ngx_conf_merge_bitmask_value(conf->next_upstream, prev->next_upstream,
(NGX_CONF_BITMASK_SET
diff --git a/src/http/modules/proxy/ngx_http_proxy_upstream.c b/src/http/modules/proxy/ngx_http_proxy_upstream.c
index bd4befd76..d27975919 100644
--- a/src/http/modules/proxy/ngx_http_proxy_upstream.c
+++ b/src/http/modules/proxy/ngx_http_proxy_upstream.c
@@ -1199,14 +1199,16 @@ static void ngx_http_proxy_send_response(ngx_http_proxy_ctx_t *p)
ep->preread_size = p->header_in->last - p->header_in->pos;
- ep->hunk_to_file = ngx_calloc_hunk(r->pool);
- if (ep->preread_hunks == NULL) {
- ngx_http_proxy_finalize_request(p, 0);
- return;
+ if (p->cachable) {
+ ep->hunk_to_file = ngx_calloc_hunk(r->pool);
+ if (ep->hunk_to_file == NULL) {
+ ngx_http_proxy_finalize_request(p, 0);
+ return;
+ }
+ ep->hunk_to_file->pos = p->header_in->start;
+ ep->hunk_to_file->last = p->header_in->pos;
+ ep->hunk_to_file->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
}
- ep->hunk_to_file->pos = p->header_in->start;
- ep->hunk_to_file->last = p->header_in->pos;
- ep->hunk_to_file->type = NGX_HUNK_IN_MEMORY|NGX_HUNK_TEMP;
if (ngx_event_flags & NGX_USE_AIO_EVENT) {
/* the posted aio operation can currupt a shadow buffer */