我有一个在Docker后面运行的Nginx。
这是我的.conf文件
events {
worker_connections 2048;
}
http {
default_type application/octet-stream;
server {
listen 80;
index index.php index.html;
root /var/www/public;
location / {
try_files $uri /index.php?$args;
}
location ~ \.css {
include /etc/nginx/mime.types;
add_header Content-Type text/css;
}
location ~ \.js {
add_header Content-Type application/x-javascript;
}
location ~ ^/(assets/|css/|js/|index.html) {
root /var/www/public;
index index.html;
access_log off;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
}
我在这里遵循了解决方案: Nginx fails to load css files
我也尝试了以下方法:
我检查了mime.types是否具有正确的值,如下所示:
text/css css;
我从Chrome开发者控制台获得的结果是:
Accept-Ranges: bytes
Content-Length: 52806
Content-Type: text/plain
Content-Type: text/css
Date: Thu, 20 Sep 2018 09:49:35 GMT
ETag: "5ba0bfef-ce46"
由于某些原因,Nginx将其全部加载为text / plain和text / css。
这是我正在使用的Nginx版本:
Server: nginx/1.15.3
编辑
有趣的是,如果我像这样卷曲-v,它将被视为text / css
有人能指出我正确的方向吗?谢谢