slice module issue if redirected origin and have have fist slice

George . george at
Mon Jun 12 07:02:16 UTC 2017

I've discovered following strange issue with http_slice_module
If I have a named location for internal 302 redirect and caching one slice
makes further request for whole object to brake upstream redirected request
(missing Rage header, see frame 254 in the attached capture ​
​ ).

 If there is no cached slice everything is okey  (2nd capture​

Problem appears in main branch and also  nginx/1.12 ... and may be in all

nginx version: nginx/1.13.2
built by gcc 4.9.2 (Debian 4.9.2-10)
configure arguments: --prefix=/home/george/run/nginx_hg

user cdnuser cdnuser;
worker_processes  1;

error_log  logs/error.log  debug;

events {
    worker_connections  1024;

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;
    tcp_nopush      on;

    proxy_cache_path /home/george/run/nginx_hg/cache/
keys_zone=zone_uid_default:4m levels=2:1 inactive=360d max_size=18329m;

    # our redirecting origin
    server {
        listen       8081;

        return 302 $scheme://$request_uri;

    # our final origin
    server {
        listen       8082;
        add_header Cache-Control "max-age=3600";
        root /home/george/run/nginx_hg/root;

    server {
        listen       8080;
        server_name  localhost;

        recursive_error_pages on;
        proxy_intercept_errors on;

        location / {
            slice             4m;
            proxy_cache       zone_uid_default;
            proxy_cache_key   $uri$is_args$args$slice_range;
            proxy_set_header  Range $slice_range;

            proxy_pass        http://localhost:8081;

            error_page 301 302 307 = @fetch_from_redirected_origin;

        location @fetch_from_redirected_origin {
            slice   4m;


            set $my_upstream_http_location $upstream_http_location;

            proxy_cache       zone_uid_default;
            proxy_cache_key   $uri$is_args$args$slice_range;
            proxy_set_header  Range $slice_range;

            proxy_pass        $my_upstream_http_location;

How to reproduce:

1. Create some empty object in our emulated origin
mkdir /home/george/run/nginx_hg/root
dd if=/dev/zero of=/home/george/run/nginx_hg/root/some_object  bs=64M

2. Ask our caching proxy for one 4m slice, so it will be cached
curl -v -r 0-4194303 "" --header "Host:
localhost" -o /dev/null

3. See it really there
george at george ~/run/nginx_hg $ head
Ļ:Y˩:Y��:YVʜ�r � "593aa9cb-4000000"
KEY: /some_objectbytes=0-4194303
HTTP/1.1 206 Partial Content
Server: nginx/1.13.2
Date: Fri, 09 Jun 2017 14:16:20 GMT
Content-Type: application/octet-stream
Content-Length: 4194304
Last-Modified: Fri, 09 Jun 2017 13:59:39 GMT
Connection: close
ETag: "593aa9cb-4000000"

4. This time request the whole object
curl -v  "" --header "Host: localhost" -o

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list