Uwsgi: missing mimetypes for static file serving

Created on 23 Jan 2015  Â·  5Comments  Â·  Source: unbit/uwsgi

It looks like something is off with mimetypes as it looks like it is not passed down to the client.

Found this because i have a specific svg not loading served by uwsgi static router. This specific svg not working is missing "" header so (i suppose) browser detection does not recognize it as a svg.

Stock uwsgi:

[uwsgi-fileserve] checking for /home/rm/work/big.svg
[uwsgi-fileserve] file /home/rm/work/big.svg found, mimetype (null)

after adding this mimefile to uwsgi conf:

image/svg+xml   svg svgz

the mimetype is not null:

[uwsgi-fileserve] checking for /home/rm/work/big.svg
[uwsgi-fileserve] file /home/rm/work/big.svg found, mimetype image/svg+xml  svg svgz

And the browsers display it correctly

Most helpful comment

set mime types file path

uwsgi --ini uwsgi.ini --mimefile /etc/mime.types

If the file /etc/mime.types does not exist, you need install mailcap

sudo yum install mailcap
or
sudo apt-get install mime-support

All 5 comments

set mime types file path

uwsgi --ini uwsgi.ini --mimefile /etc/mime.types

If the file /etc/mime.types does not exist, you need install mailcap

sudo yum install mailcap
or
sudo apt-get install mime-support

NB: uwsgi expects a plain text format of mimetypes, as opposed to nginx's dict-like; e.g.:
https://raw.githubusercontent.com/lucidfrontier45/docker-python-uwsgi/master/mime.types

FWIW, I found that I didn't actually need to tell uwsgi where this file is, I just needed to install install apk add mailcap (this is on Alpine Linux). After doing that, it started serving SVGs with the correct mime type.

FWIW, I found that I didn't actually need to tell uwsgi where this file is, I just needed to install install apk add mailcap (this is on Alpine Linux). After doing that, it started serving SVGs with the correct mime type.

I spent a good few hours try to understand why chrome and safari won't display the SVG logo I have (FF worked). And eventually that did it!

sudo apt-get install -y mime-support

was enough for my case.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pdonadeo picture pdonadeo  Â·  5Comments

ilrico picture ilrico  Â·  7Comments

cancan101 picture cancan101  Â·  4Comments

GaretJax picture GaretJax  Â·  7Comments

yoichi picture yoichi  Â·  7Comments