Welcome! Log In Create A New Profile


Re: File Downloads with reverse proxy

Francis Daly
March 16, 2019 05:58AM
On Fri, Mar 15, 2019 at 02:17:01PM +0000, Callum Scott wrote:

Hi there,

> I am having difficulty forcing downloads of mp4 files with a ?download
> query in the url.
> I am proxying files from an s3 bucket like this
> location ~* ^/myvideo/content/(.*) {
> proxy_pass http://s3.amazonaws.com;
> }
> and have another location section like this
> location ~* (.*\.mp4\?download) {
> autoindex off;
> expires 365d;
> add_header Pragma public;
> add_header Cache-Control "public";
> if ($arg_dl = "1") {
> add_header Content-disposition "attachment; filename=$1";
> }
> }

> I was expecting the video to download in this case, however it is just
> streamed instead as it would be without the ?download query.
> Can somone please suggest where I am going wrong?

* one request is handled in one location, so if your second location is
used, the proxy_pass from the first is not used. See http://nginx.org/r/location

* $arg_dl is the value of the "dl" argument. Possibly you want
$arg_download, or 'if ($args = "download")'. See http://nginx.org/r/$arg_

* nginx does not use the query string (? part) in choosing which location
to use. So your second location will not match any "normal" requests.

I'm not certain what your overall requirements are; but possibly the
simplest config would be not to configure things specially, and just
let the client decide what they want to download by using their "save
link as" feature.

I hope this points you in the right direction.


Francis Daly francis@daoine.org
nginx mailing list
Subject Author Posted

File Downloads with reverse proxy

Callum Scott March 15, 2019 10:18AM

Re: File Downloads with reverse proxy

Francis Daly March 16, 2019 05:58AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready