Nginx – How to specify mimetype of files with no extension in NGINX config

mime-typesnginx

I have a server with nginx. And I have a lot of images – pngs and jpgs saved as files with no extension (like "123123123_321312").

When I use tag "img" in html page, I get theese messages in console:

Resource interpreted as Image but transferred with MIME type application/octet-stream: "http://xxxx/images/1350808948_997628". jquery.js:2
Resource interpreted as Image but transferred with MIME type application/octet-stream: "http://xxxx/images/1343808569_937350". 

Is there a way to make nginx add header with correct mimetype of the requested file?

Best Answer

You should use the default_type directive :

server {
   ...
   default_type text/html;

   location /images/png {
      default_type image/png;
   }

   location /images/jpg {
      default_type image/jpeg;
   }
}