Search code examples
nginxhttp-content-range

nginx proxy pass content range


How can I make nginx to send source server if Range header is passed by user?

Currently I am tried this, but not worked:

server {
    location / {
        if ($http_range) {
            set $var_arg_range $http_range;
        }
        if ($arg_range) {
            set $var_arg_range "bytes=$arg_range";
        }
        proxy_set_header Range $var_arg_range;
        proxy_pass https://content-na.drive.amazonaws.com;
        proxy_set_header If-Range "";
        proxy_set_header Host content-na.drive.amazonaws.com;
        proxy_set_header Range $var_arg_range;
        proxy_set_header Accept-Encoding "";
    }
}

I need to make html5 videos streamable.


Solution

  • Finally I found it. I need to pass headers to source server with proxy_pass_request_headers. And don't forget to pass your custom Referer header:

    server {
                postpone_output 0;
                resolver 8.8.8.8;
                proxy_set_header Referer        "https://content-na.drive.amazonaws.com";
                proxy_set_header Host           "content-na.drive.amazonaws.com";
                proxy_pass_request_headers      on;
                proxy_ssl_verify                off;
                proxy_method                    "GET";
                proxy_pass                      https://content-na.drive.amazonaws.com;
    }