Hello,

I think Nginx misses a small feature when used as a video
caching proxy. MP4 files have a MOOV atom on top - so it
would be great to tell a caching proxy to throttle the bandwidth
only after sending the MOOV atom (the MOOV atom should be
shipped as fast as possible).

An nginx server can use "limit_rate_after <moov-atom-size>" -
but can't tell a caching proxy to do so.

It would be great if "X-Accel-Limit-Rate" could support an optional
second parameter: "limit-rate-after", e.g.:

        X-Accel-Limit-Rate: <limit-rate> <limit-rate-after>

A small patch should be attached.
Thanks a lot
Markus

*** ./src/http/ngx_http_upstream.c-orig	2016-04-19 21:21:31.331726509 +0200
--- ./src/http/ngx_http_upstream.c	2016-04-21 11:46:34.663569318 +0200
*************** static ngx_int_t
*** 4511,4517 ****
  ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h,
      ngx_uint_t offset)
  {
!     ngx_int_t             n;
      ngx_http_upstream_t  *u;
  
      u = r->upstream;
--- 4511,4518 ----
  ngx_http_upstream_process_limit_rate(ngx_http_request_t *r, ngx_table_elt_t *h,
      ngx_uint_t offset)
  {
!     ngx_int_t             n, na = NGX_ERROR;
!     u_char               *p;
      ngx_http_upstream_t  *u;
  
      u = r->upstream;
*************** ngx_http_upstream_process_limit_rate(ngx
*** 4521,4531 ****
          return NGX_OK;
      }
  
!     n = ngx_atoi(h->value.data, h->value.len);
  
      if (n != NGX_ERROR) {
          r->limit_rate = (size_t) n;
      }
  
      return NGX_OK;
  }
--- 4522,4539 ----
          return NGX_OK;
      }
  
!     p = (u_char *) ngx_strchr(h->value.data, ' ');
!     n = ngx_atoi(h->value.data, p != NULL ? (size_t)(p - h->value.data) : h->value.len);
!     if (p != NULL) {
!         na = ngx_atoi(p + 1, h->value.len - (p - h->value.data) - 1);
!     }
  
      if (n != NGX_ERROR) {
          r->limit_rate = (size_t) n;
      }
+     if (na != NGX_ERROR) {
+         r->limit_rate_after = (size_t) na;
+     }
  
      return NGX_OK;
  }
_______________________________________________
nginx-devel mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to