I recently had a very weird issue with Nginx serving static content. A Latin-script letter
Â keeps showing up in one of my CSS files, and the letters are not in the actual file. It turns out that Nginx doesn't set
chartset by default, that's why the characters not in the ISO basic alphabet got decoded to something else.
We'll be using
ngx_http_charset_module to configure charset in Nginx. This module comes by default, no extra installation needed.
off by default, set it to
utf-8 so it appends
charset=utf-8 after MIME type in
charsetcan be set in
By default, Nginx will only append charset to MIME types of
application/rss+xml. To change that:
charset_typescan be set in
text/htmlcan be excluded, since it's enabled by default according to the official documentation.
Reload Nginx to apply changes:
$ sudo nginx -s reload
Use development tools of your browser to verify static files are served with