I have a directory index configured and every time I click a file it gets downloaded.
I want to tell nginx to show the content for text files instead of downloading them.
I still want the download to work when I use wget on those text files.
How can I do that?
Just set the content type in the location
block.
In my case I want to serve a VERSION
file, but by default the browser downloads it (because it's served as application/x-octet-stream
). If I make nginx send it with a Content-type of text/plain, the browser will display it instead of downloading it.
location = /VERSION {
root /usr/share/nginx/html;
add_header Cache-Control 'must-revalidate';
add_header Content-Type text/plain;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With