slice module issue if redirected origin and have have fist slice

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


​​Hi,
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 ​
 slice_redirect_problem.pcapng
<https://drive.google.com/a/ucdn.com/file/d/0ByZ2nt00gtJ2NmtqVUU3OVozNXM/view?usp=drive_web>
​ ).

 If there is no cached slice everything is okey  (2nd capture​
 slice_redirect_no_problem.pcapng
<https://drive.google.com/a/ucdn.com/file/d/0ByZ2nt00gtJ2SUpnc2VVbzBKdWc/view?usp=drive_web>
​)

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

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
--with-http_slice_module




nginx.conf
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://127.0.0.1:8082$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;

            internal;

            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
count=1

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

3. See it really there
george at george ~/run/nginx_hg $ head
/home/george/run/nginx_hg/cache/81/c/00214df7041ea53dd335ed5b055bfc81
Ļ: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  "http://127.0.0.1:8080/some_object" --header "Host: localhost" -o
/dev/null


​​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20170612/39b99d35/attachment.html>


More information about the nginx-devel mailing list