Skip to content

Instantly share code, notes, and snippets.

@D4R4
Created February 20, 2019 17:41
Show Gist options
  • Save D4R4/488318e68a2272874c4d5737f53be9b0 to your computer and use it in GitHub Desktop.
Save D4R4/488318e68a2272874c4d5737f53be9b0 to your computer and use it in GitHub Desktop.
Tell nginx to treat mp3 mp4 and any media extention as attachment and go straight to download instead of browser player
location ~ ^.*/(?P<request_basename>[^/]+\.(mp4))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
location ~ ^.*/(?P<request_basename>[^/]+\.(mp3))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
location ~ ^.*/(?P<request_basename>[^/]+\.(ogg))$ {
add_header Content-Disposition 'attachment; filename="$request_basename"';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment