Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NGINX - Can't set content-type header

I'm using nginx/1.10-3 on Debian.

I have a file named logo.img which infact is an svg.

I've modified /etc/nginx/mime.types to include the .img as an extension for the svg file type: image/svg+xml svg svgz img;

But the headers of the file served is still application/octet-stream

For some bizarre reason, i've been asked to serve the .img file as an svg for a logo on a site, i've got it to work on Apache2 using mime magic. But, as far as i know, that doesn't exist on NGINX.

like image 920
Lloyd Owen Avatar asked Sep 14 '25 22:09

Lloyd Owen


1 Answers

The /etc/nginx/mime.types file already contains a mapping for URIs ending with .img, which is set to application/octet-stream.

When you edit the file, did must also remove this existing mapping.


Alternatively, you can override the content-type for a single URI.

For example:

root /path/to/root;
...
location = /images/logo.img {
    types {}
    default_type image/svg+xml;
}
like image 91
Richard Smith Avatar answered Sep 16 '25 18:09

Richard Smith