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

**URL:** <https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342>\
**Category:** NGINX\
**Created:** [August 25, 2009, 11:06am UTC](https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342 "2009-08-25T11:06:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [August 25, 2009, 11:06am UTC](https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342/1 "2009-08-25T11:06:24Z")

</div>

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:

> **[How to config nginx to download html file instead of opening it?](https://forum.nginx.org/read.php?2,5148,5148#msg-5148)**
>
> 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

---

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [August 25, 2009, 11:38am UTC](https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342/2 "2009-08-25T11:38:37Z")

</div>

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 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [August 25, 2009, 11:56am UTC](https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342/3 "2009-08-25T11:56:11Z")

</div>

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; }  
…  
}

---

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [August 26, 2009, 9:35pm UTC](https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342/4 "2009-08-26T21:35:16Z")

</div>

Thanks! It works very well.

Posted at Nginx Forum:

> **[Re: How to config nginx to download html file instead of opening it?](https://forum.nginx.org/read.php?2,5148,5176#msg-5176)**
>
> 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

---

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [August 28, 2009, 3:25am UTC](https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342/5 "2009-08-28T03:25:59Z")

</div>

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:

> **[Re: How to config nginx to download html file instead of opening it?](https://forum.nginx.org/read.php?2,5148,5251#msg-5251)**
>
> 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

---

<div class="post-metadata">

**Author:** ![jzhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/df788c/32.png) [@jzhang](https://www.ruby-forum.com/u/jzhang)\
**Post date:** [August 28, 2009, 3:35pm UTC](https://www.ruby-forum.com/t/how-to-config-nginx-to-download-html-file-instead-of-opening-it/174342/6 "2009-08-28T15:35:54Z")

</div>

Make sure the following HTTP header is present:

```
Content-Disposition: attachment

```

According to the article at

> **[Internet Explorer MIME Handling Enforcement](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2003/cc787872(v=ws.10)?redirectedfrom=MSDN)**

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
