docker - Nginx 无法加载 text/css(在 docker 下运行)
问题描述
我有一个在 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 无法加载 css 文件
我也尝试过以下方法:
- 把包括/etc/nginx/mime.types; 在 http {
我检查了 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
编辑
有趣的是,如果我像这样 curl -v ,它将被视为文本/css
谁能指出我正确的方向?谢谢
解决方案
推荐阅读
- python - 使用 Ctypes 在 Python 程序中通过引用 c 程序调用调用
- python - 如何递归地对python对象进行jsonize
- apache-kafka - Kafka 主题似乎只在第一次起作用。为什么?
- here-api - 地图无法在 OnePlus 5T 上的 Chrome 上加载
- r - 在 R Keras 中重塑张量以使用 Weibull 分布进行训练
- rdf - 是否可以使用 RDF 模式通过 Microdata 定义特定的 Schema.org“受众”?
- php - 如何在 CONTROLLER 中为 laravel foreach 循环中的第一项传递特殊值
- c++ - 在 C++ 中正确实现复制构造函数
- oracle - PL/SQL:While Loop 不等待内部过程完成
- java - 如何在 getJdbcTemplate().query 中将 postgresql 数组转换为 java 数组