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

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

Make sure the following HTTP header is present:

    Content-Disposition: attachment

According to the article at
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:

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


On Thu, Aug 27, 2009 at 8:18 PM, jzhang<nginx-forum at> 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:,5148,5251#msg-5251

More information about the nginx mailing list