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

Hello everyone,
I want to config the server when user access a html file, the browser
would popup the Save File dialog,
instead of opening it in window. Your help will be appreciated greatly.

Jason Zhang

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5148,5148#msg-5148

Hi,

in the mime.types file, remove the extension html from the text/html
file. It should do the trick.

++ Jerome

2009/8/25 jzhang [email protected]:

On Tue, Aug 25, 2009 at 11:29:57AM +0200, J?r?me Loyet wrote:

Hi,

in the mime.types file, remove the extension html from the text/html
file. It should do the trick.

It’s better to set new “types” for location:

location /saveonly/ {
types { application/octet-stream html; }

}

Thanks! It works very well.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,5148,5176#msg-5176

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

Make sure the following HTTP header is present:

Content-Disposition: attachment

According to the article at
http://technet.microsoft.com/en-us/library/cc787872(WS.10).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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs