Welcome! Log In Create A New Profile

Advanced

[nginx] Upstream: proxy_force_ranges and friends.

Roman Arutyunyan
October 14, 2014 10:40AM
details: http://hg.nginx.org/nginx/rev/2aff40b3dea2
branches:
changeset: 5874:2aff40b3dea2
user: Roman Arutyunyan <arut@nginx.com>
date: Tue Oct 14 18:32:01 2014 +0400
description:
Upstream: proxy_force_ranges and friends.

The directives enable byte ranges for both cached and uncached
responses regardless of backend headers.

diffstat:

src/http/modules/ngx_http_fastcgi_module.c | 11 +++++++++++
src/http/modules/ngx_http_proxy_module.c | 11 +++++++++++
src/http/modules/ngx_http_scgi_module.c | 11 +++++++++++
src/http/modules/ngx_http_uwsgi_module.c | 11 +++++++++++
src/http/ngx_http_upstream.c | 15 +++++++++++++++
src/http/ngx_http_upstream.h | 1 +
6 files changed, 60 insertions(+), 0 deletions(-)

diffs (183 lines):

diff -r 35b8e5e98508 -r 2aff40b3dea2 src/http/modules/ngx_http_fastcgi_module.c
--- a/src/http/modules/ngx_http_fastcgi_module.c Sat Oct 11 21:09:29 2014 +0900
+++ b/src/http/modules/ngx_http_fastcgi_module.c Tue Oct 14 18:32:01 2014 +0400
@@ -326,6 +326,13 @@ static ngx_command_t ngx_http_fastcgi_c
offsetof(ngx_http_fastcgi_loc_conf_t, upstream.busy_buffers_size_conf),
NULL },

+ { ngx_string("fastcgi_force_ranges"),
+ 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_fastcgi_loc_conf_t, upstream.force_ranges),
+ NULL },
+
#if (NGX_HTTP_CACHE)

{ ngx_string("fastcgi_cache"),
@@ -2332,6 +2339,7 @@ ngx_http_fastcgi_create_loc_conf(ngx_con
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
conf->upstream.buffering = NGX_CONF_UNSET;
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
+ conf->upstream.force_ranges = NGX_CONF_UNSET;

conf->upstream.local = NGX_CONF_UNSET_PTR;

@@ -2413,6 +2421,9 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf
ngx_conf_merge_value(conf->upstream.ignore_client_abort,
prev->upstream.ignore_client_abort, 0);

+ ngx_conf_merge_value(conf->upstream.force_ranges,
+ prev->upstream.force_ranges, 0);
+
ngx_conf_merge_ptr_value(conf->upstream.local,
prev->upstream.local, NULL);

diff -r 35b8e5e98508 -r 2aff40b3dea2 src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c Sat Oct 11 21:09:29 2014 +0900
+++ b/src/http/modules/ngx_http_proxy_module.c Tue Oct 14 18:32:01 2014 +0400
@@ -389,6 +389,13 @@ static ngx_command_t ngx_http_proxy_com
offsetof(ngx_http_proxy_loc_conf_t, upstream.busy_buffers_size_conf),
NULL },

+ { ngx_string("proxy_force_ranges"),
+ 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_proxy_loc_conf_t, upstream.force_ranges),
+ NULL },
+
#if (NGX_HTTP_CACHE)

{ ngx_string("proxy_cache"),
@@ -2472,6 +2479,7 @@ ngx_http_proxy_create_loc_conf(ngx_conf_
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
conf->upstream.buffering = NGX_CONF_UNSET;
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
+ conf->upstream.force_ranges = NGX_CONF_UNSET;

conf->upstream.local = NGX_CONF_UNSET_PTR;

@@ -2568,6 +2576,9 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t
ngx_conf_merge_value(conf->upstream.ignore_client_abort,
prev->upstream.ignore_client_abort, 0);

+ ngx_conf_merge_value(conf->upstream.force_ranges,
+ prev->upstream.force_ranges, 0);
+
ngx_conf_merge_ptr_value(conf->upstream.local,
prev->upstream.local, NULL);

diff -r 35b8e5e98508 -r 2aff40b3dea2 src/http/modules/ngx_http_scgi_module.c
--- a/src/http/modules/ngx_http_scgi_module.c Sat Oct 11 21:09:29 2014 +0900
+++ b/src/http/modules/ngx_http_scgi_module.c Tue Oct 14 18:32:01 2014 +0400
@@ -183,6 +183,13 @@ static ngx_command_t ngx_http_scgi_comma
offsetof(ngx_http_scgi_loc_conf_t, upstream.busy_buffers_size_conf),
NULL },

+ { ngx_string("scgi_force_ranges"),
+ 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_scgi_loc_conf_t, upstream.force_ranges),
+ NULL },
+
#if (NGX_HTTP_CACHE)

{ ngx_string("scgi_cache"),
@@ -1091,6 +1098,7 @@ ngx_http_scgi_create_loc_conf(ngx_conf_t
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
conf->upstream.buffering = NGX_CONF_UNSET;
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
+ conf->upstream.force_ranges = NGX_CONF_UNSET;

conf->upstream.local = NGX_CONF_UNSET_PTR;

@@ -1167,6 +1175,9 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t
ngx_conf_merge_value(conf->upstream.ignore_client_abort,
prev->upstream.ignore_client_abort, 0);

+ ngx_conf_merge_value(conf->upstream.force_ranges,
+ prev->upstream.force_ranges, 0);
+
ngx_conf_merge_ptr_value(conf->upstream.local,
prev->upstream.local, NULL);

diff -r 35b8e5e98508 -r 2aff40b3dea2 src/http/modules/ngx_http_uwsgi_module.c
--- a/src/http/modules/ngx_http_uwsgi_module.c Sat Oct 11 21:09:29 2014 +0900
+++ b/src/http/modules/ngx_http_uwsgi_module.c Tue Oct 14 18:32:01 2014 +0400
@@ -238,6 +238,13 @@ static ngx_command_t ngx_http_uwsgi_comm
offsetof(ngx_http_uwsgi_loc_conf_t, upstream.busy_buffers_size_conf),
NULL },

+ { ngx_string("uwsgi_force_ranges"),
+ 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_uwsgi_loc_conf_t, upstream.force_ranges),
+ NULL },
+
#if (NGX_HTTP_CACHE)

{ ngx_string("uwsgi_cache"),
@@ -1271,6 +1278,7 @@ ngx_http_uwsgi_create_loc_conf(ngx_conf_
conf->upstream.next_upstream_tries = NGX_CONF_UNSET_UINT;
conf->upstream.buffering = NGX_CONF_UNSET;
conf->upstream.ignore_client_abort = NGX_CONF_UNSET;
+ conf->upstream.force_ranges = NGX_CONF_UNSET;

conf->upstream.local = NGX_CONF_UNSET_PTR;

@@ -1354,6 +1362,9 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t
ngx_conf_merge_value(conf->upstream.ignore_client_abort,
prev->upstream.ignore_client_abort, 0);

+ ngx_conf_merge_value(conf->upstream.force_ranges,
+ prev->upstream.force_ranges, 0);
+
ngx_conf_merge_ptr_value(conf->upstream.local,
prev->upstream.local, NULL);

diff -r 35b8e5e98508 -r 2aff40b3dea2 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c Sat Oct 11 21:09:29 2014 +0900
+++ b/src/http/ngx_http_upstream.c Tue Oct 14 18:32:01 2014 +0400
@@ -2276,6 +2276,17 @@ ngx_http_upstream_process_headers(ngx_ht

r->disable_not_modified = !u->cacheable;

+ if (u->conf->force_ranges) {
+ r->allow_ranges = 1;
+ r->single_range = 1;
+
+#if (NGX_HTTP_CACHE)
+ if (r->cached) {
+ r->single_range = 0;
+ }
+#endif
+ }
+
u->length = -1;

return NGX_OK;
@@ -4393,6 +4404,10 @@ ngx_http_upstream_copy_allow_ranges(ngx_
{
ngx_table_elt_t *ho;

+ if (r->upstream->conf->force_ranges) {
+ return NGX_OK;
+ }
+
#if (NGX_HTTP_CACHE)

if (r->cached) {
diff -r 35b8e5e98508 -r 2aff40b3dea2 src/http/ngx_http_upstream.h
--- a/src/http/ngx_http_upstream.h Sat Oct 11 21:09:29 2014 +0900
+++ b/src/http/ngx_http_upstream.h Tue Oct 14 18:32:01 2014 +0400
@@ -162,6 +162,7 @@ typedef struct {
ngx_flag_t ignore_client_abort;
ngx_flag_t intercept_errors;
ngx_flag_t cyclic_temp_file;
+ ngx_flag_t force_ranges;

ngx_path_t *temp_path;


_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Upstream: proxy_force_ranges and friends.

Roman Arutyunyan 1442 October 14, 2014 10:40AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 160
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready