Default MIME type to use when serving files nginx

Revision history
Tags: nginx

I am serving some shell scripts without a file extension on my nginx web server which by default was serving these files with Content-Type: application/octet-stream. By using the option default_type I can choose what MIME type to use for files that are not already specified with the types {} directive.

Configuring my server to serve unknown file types as text/plain within a specific site:

server {
  listen 80;
  listen [::]:80;
  listen 443 ssl;
  listen [::]:443 ssl;
  root /var/www/example.com/public;
  server_name example.com;

  default_type text/plain;
}

Resources

If you have any comments or feedback, please send me an e-mail. (stig at stigok dotcom).

Did you find any typos, incorrect information, or have something to add? Then please propose a change to this post.

Creative Commons License This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.