Nginx 配置导致 CSS 文件返回 Content-Type 为 text/html?
环境:nginx1.26.1
请求 CSS 文件,Content-Type 为 text/html
引用 css 的 html 代码为:
<link rel="stylesheet" type="text/css" href="css/main.css">
nginx.conf 配置中相关部分:
http {
include mime.types;
default_type application/octet-stream;
...
server {
listen 80;
server_name localhost;
location / {
root /home/totorocat/myimageboard;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
mime.types 与 nginx.conf 文件均存在于/etc/nginx
下,nginx 已重载配置,错误记录与访问记录均无有用信息
尝试本站同类问题解决方案,无效
尝试清除浏览器记录,无效
希望加载 css 文件时得到正确的 content-type,诚恳请教大佬们!
回复
1个回答

test
2024-08-11
- 怀疑是 404,然后返回了错误页,这个在前端项目部署时很常见
- 看起来你用了反向代理,所以要看下原服务器返回的是什么
- 确保你的配置是正确的
- 不要尝试“同类问题解决方案”,要找到问题症结,从逻辑角度推导,然后尝试解决问题
回复

适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容