Because Nginx won’t add the file name into the Content-Disposition value, we need to “tell” it to change the format of the header so it includes the file name. This way we can save the file by it’s original name.

Nginx configuration block

location / {
        add_header Content-Disposition 'attachment; filename="$baseuri"';

CURL Example

curl -I
HTTP/1.1 200 OK
Date: Sat, 07 Mar 2015 23:39:57 GMT
Content-Type: text/html;charset=UTF-8
Connection: keep-alive
Cache-Control: private
Vary: Accept-Encoding
Accept-Ranges: bytes
Server: NetDNA-cache/2.2
Content-Disposition: attachment; filename="example.html"
Link: ; rel="canonical"
X-Cache: MISS