Nginx offers to download SVG instead of showing it

佐手、 提交于 2019-12-10 13:32:58

问题


I try to show SVG file in HTML or separate tab but Nginx offers me to download it. I took normal SVG file which works on another site but not in my server.

Where is a problem?

Here is an example http://proximax.ru/media/content/final/plane2.svg Also here SVG in HTML http://proximax.ru/index/


回答1:


The of your image is noted as application/octet-stream which a browser can only offer to download as it does not know how to interpret it.

From your index.html file it is clear that you were playing around with variations of the MIME-type, and it is unclear whether the standard requires image/svg or image/svg+xml (or standards being what they are, something else entirely).




回答2:


I fixed it. I added to /etc/nginx/mime.types

image/svg+xml svg svgz;

Then I checked that server responses correctly

wget -O - -S http://proximax.ru/media/content/final/avW30U.svg > /dev/null
..
Content-Type: image/svg+xml
..

Also I turned off other virtual spaces for be clear.




回答3:


In my case, I put default_type application/octet-stream; after the include mime.types; cause the problem. And simply switch them fixed it. ^_^



来源:https://stackoverflow.com/questions/3695409/nginx-offers-to-download-svg-instead-of-showing-it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!