Drawing a Blank
by Mike Fulcher

Font mime types in Nginx
Saturday, June 08, 2013

The default Nginx configuration doesn’t contain mime types for fonts, so here are a couple of easy steps to ensure your fonts are served with the correct mime type and are gzipped to reduce file size.

Adding new mime types

On a default install (built from source) the Nginx mime types are defined in /usr/local/nginx/conf/mime.types. Just add these lines:

font/ttf                      ttf;
font/opentype                 otf;
application/font-woff         woff;
application/vnd.ms-fontobject eot;

And remove the existing line for eot (defaults to application/octet-stream). You shouldn’t need to add one for svg, either.

Gzipping

You can gzip all font formats except woff (which is already compressed). Simply add the mime types for ttf, otf, eot, and svg to the gzip_types collection:

gzip_types [...] font/ttf font/opentype application/vnd.ms-fontobject image/svg+xml;