Apache httpd vs nginx: auto detect content-type

半腔热情 提交于 2019-12-13 05:02:00

问题


I'm developing an Avatar storage & display module for my site.

In my design, I store user's avatar as a file on HDD, and name it based on user id. For example, user with uid=100 has an avatar in following path: /data/avatars/100.ava.

I allow users to upload .jpg, .png, .gif images for their avatar. After users uploaded avatar, my server will crop & resize it to 200x200px, and rename file to .ava.

For displaying, I find out that there is a difference between Apache httpd and Nginx.

For Apache httpd: I config a virtual host called avatar.mysite.com, and point root directory to /data/avatars. When I use Chrome browser to visit http://avatar.mysite.com/100.ava, the browser display avatar correctly, with proper Content-type header in response (I tried .gif, .jpg & .png, all are ok)

For nginx: I config a virtual host called avatar.mysite.com, and point root directory to /data/avatars, too. But when I visit http://avatar.mysite.com/100.ava, the browser downloads file 100.ava (instead of displays it). As I checked, the content-type for .ava always be application/octet-stream

So, how could I config nginx to response correct content-type in this sistuation?

Thank you in advanced!

来源:https://stackoverflow.com/questions/25988615/apache-httpd-vs-nginx-auto-detect-content-type

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