Do I need to configure SVG images showing in nginx?
Add SVG image/svg+xml svg svgz;
to your mime types in /etc/nginx/mime.types
and reload your Nginx.
When Nginx doesn't recognize the mime type for .svg
files, it serves them with content type header content-type: text/plain
and your browser may not render them or may issue a warning to the web console.
-
Ensure that
/etc/nginx/mime.types
defines a mime type for svg images:types { ... image/svg+xml svg svgz; ... }
-
Ensure that
/etc/nginx/nginx.conf
includes themime.types
file in the http block:http { include mime.types; ... }
-
In the terminal check that your new nginx configuration has no errors:
sudo nginx -t
-
Restart NGINX for the changes to take effect
sudo systemctl restart nginx // e.g.: ubuntu
In your browser dev tools under network headers, check that svg files are served with header
Content-Type: image/svg+xml
and possibly hard refresh your web page to update the browser cache.