F
F
Fyodor2014-10-26 15:46:57
Apache HTTP Server
Fyodor, 2014-10-26 15:46:57

How to set up in ngnix so that a download request is issued during direct access?

We switched to another hosting, and there ngnix is ​​configured to distribute statics.
It is necessary that when accessing certain types of files in certain folders (mp3 mp4 png), an offer to download the file was issued. Now the file is played directly in the browser. Of course, you can process these files through Apache, but it turns out wrong ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
neolink, 2014-10-26
@neolink

Something like this:

if ($request_filename ~ "([^/]+\.(mp3|mp4|png))$"){
    set $fname $1;
    add_header Content-Disposition 'attachment; filename="$fname"';
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question