2

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.

1 Answers1

5

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;
}
  • 1
    Not sure if this directive fixed it as default value for `proxy_pass_request_headers` is `on` [docs](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass_request_headers) – Casey Dec 18 '18 at 15:01