<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Hi!
<br>
<br>
<blockquote type="cite" style="color: #000000;">to nginx, as
follows:
<br>
<br>
<br>
location / {
<br>
<br>
# force download for ceratain file types
<br>
location ~* \.(?:fb2|mobi|mp3)$ {
<br>
add_header Content-Disposition "attachment";
<br>
}
<br>
location ~* \.fb2$ {
<br>
add_header Content-type "text/fb2+xml";
<br>
}
<br>
location ~* \.mobi$ {
<br>
add_header Content-type "application/x-mobipocket-ebook";
<br>
} <br>
location ~* \.mp3$ {
<br>
add_header Content-type "audio/mpeg";
<br>
}
<br>
<br>
...
<br>
}
<br>
<br>
Content-Disposition "attachment" seems to be added properly to the
<br>
header, however not the Content-type. Why? Can several sibling
location
<br>
blocks that match be proceeded or only one?
<br>
</blockquote>
Several things to note here:
<br>
- nesting is completely unnecessary here since you use the default
location which always matches (if there are no other rules being
more specific)
<br>
- when processing a request, nginx will search for exactly one
location that matches your request, following the rules described in
detail in the docs: <a class="moz-txt-link-freetext"
href="http://nginx.org/en/docs/http/ngx_http_core_module.html#location">http://nginx.org/en/docs/http/ngx_http_core_module.html#location</a>
<br>
- regex locations are considered in order or appearance. Your first
location is found and used, and only that one.
<br>
- stop thinking apache (I believe I alread told you that? ;-)):
check the mime.types file of nginx in <i class="moz-txt-slash"><span
class="moz-txt-tag">/</span>etc/nginx<span class="moz-txt-tag">/</span></i>.
It comes with the installation and this is how you specify
content-type headers. If the provided mapping doesn't suite you,
create your own and include that instead. So you dont need all your
content-type locations at all.
<br>
<br>
And use the docs, they are pretty concise (sometimes you need to
read a couple of times, but it almost always turns out to be
accurate :-))
<br>
<a class="moz-txt-link-freetext" href="http://nginx.org/en/docs/">http://nginx.org/en/docs/</a>
<br>
<br>
And I promise you once again, once you know how to configure nginx
and once it works for you, you'll wonder how you ever could have
used Apache (just my personal opinion, of course!)
<br>
<br>
Cheers, Ingo =;->
</body>
</html>