behnam behnam - 16 days ago 5
Linux Question

Nginx force download specific extensions

I'm using this code inside server block to force download mp3 files

location ~ /mp3folder/.+\.mp3$ {
types {
application/octet-stream;
}
}


I want to specify multiple extensions like mp4, wmv, flv ... what changes should make for this?

Answer

You can use

/mp3folder/.+\.(mp3|mp4|wmv|flv)$