技术解析
昨天配置 Nginx+gunicorn+flask 环境,配置 nginx 之前测试是可以正常显示的,一加了 nginx 之后 chrome 就显示Resource interpreted as Stylesheet but transferred with MIME type text/plain
,之后试过在 nginx.conf 中加入include mime.types;
和add_header content-type text/css;
都没用,后面只能把!DOCTYPE html
去掉勉强解决。但是还是想不明白,到底是哪里导致 CSS 的类型出错的?请各位指教
引用 CSS 的语句类似这样:
nginx 配置文件如下(因为非 root 用户运行,所以由 iptables 再转成 80 端口):
include /usr/local/nginx/conf/mime.types;
default_type application/octet-stream;
server
{
listen 8080;
server_name localhost;
access_log /home/ubuntu/nginx/access.log;
error_log /home/ubuntu/nginx/error.log;
location /
抗投诉服务器 {
proxy_pass http://localhost:8000/;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}