How to config nginx to download html file instead of opening it?

Nick Pearson nick.pearson at gmail.com
Fri Aug 28 17:27:21 MSD 2009


Make sure the following HTTP header is present:

    Content-Disposition: attachment

According to the article at
http://technet.microsoft.com/en-us/library/cc787872%28WS.10%29.aspx
this header will

    These changes do not affect cases where a
    "Content-disposition=attachment" HTTP header is used
    for the file. In those cases, the file name or
    extension suggested by the server is considered final
    and the file can be executed regardless of
    MIME/extension mismatch if the user chooses to accept
    the file download prompt.

There are also some meta tags you can use (either in the page or as an
HTTP header) that IE recognizes which will give you more fine-grained
control, but it appears that most of the useful ones weren't
introduced until IE 8.  Specifically, X-Content-Type-Options:

    http://blogs.msdn.com/ieinternals/archive/2009/06/30/Internet-Explorer-Custom-HTTP-Headers.aspx

Another common solution to this problem is to simply add .txt to the
end of the file names, such as page.html.txt

Nick


On Thu, Aug 27, 2009 at 8:18 PM, jzhang<nginx-forum at nginx.us> wrote:
> Hi All,
> I got into a new problem. The IE browser ignore the mime-type provided by nginx server, and open html document directly.
> From MS's site, it declare IE will use the extension name to detect the mime-type.
>
> Anybody know how to disable IE doing this?
>
> Thanks!
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,5148,5251#msg-5251
>
>
>





More information about the nginx mailing list