浏览器报错 net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK) 解决办法
source link: https://sunct.github.io/posts/329f423.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
浏览器报错 net::ERR_CONTENT_LENGTH_MISMATCH 200 (OK) 解决办法
一、发现问题
在开发过程中,遇到前端页面加载css,js或woff,ttf 文件的时候,经常出现 ERR_CONTENT_LENGTH_MISMATCH
的报错情况。但不是所有的js或css 报错,报错的文件较没报错的文件偏大。并且报错的文件也可以单独在浏览器中打开,所以排除了最简单的地址错误。前端项目是由nginx代理的,所以可以查看nginx的日志,看看有无线索。
二、解决问题
查找 nginx 错误日志文件
1、查找nginx配置文件
ps -ef grep nginx |
结果如下:
www 16951 18739 0 16:15 ? 00:00:00 nginx: worker process |
我的开发环境nginx配置文件路径为: /usr/local/nginx/conf/nginx.conf
2、查看错误日志文件位置
cat /usr/local/nginx/conf/nginx.conf |
我的开发环境nginx错误日志路径为:cnk_data/nginx_logs/error.log
3、打开错误日志
根据出错的文件过滤一下(若文件过大,请稍等片刻):
cat /cnk_data/nginx_logs/error.log grep "query.dataTables.min.js" |
结果如下:
2019/10/16 16:11:37 [crit] 5878#0: *81035 mkdir() "/usr/local/openresty/nginx/proxy_temp/2/35" failed (13: Permission denied) while reading upstream, client: 123.116.114.84, server: sunct.goapi.youlai.cn, request: "GET /static/js/adminone/jquery.dataTables.min.js HTTP/1.1", upstream: "http://127.0.0.1:9092/static/js/adminone/jquery.dataTables.min.js", host: "sunct.goapi.youlai.cn", referrer: "http://sunct.goapi.youlai.cn/admin/index" |
其中有一句 mkdir() Permission denied 错误:
2019/10/16 16:11:36 [crit] 5881#0: *80999 mkdir()
"/usr/local/openresty/nginx/proxy_temp/1/35"
failed (13: Permission denied) while reading upstream, client: 123.116.114.84, server: sunct.goapi.youlai.cn, request: “GET /static/js/adminone/jquery.dataTables.min.js HTTP/1.1”, upstream: “http://127.0.0.1:9092/static/js/adminone/jquery.dataTables.min.js”, host: “sunct.goapi.youlai.cn”, referrer: “http://sunct.goapi.youlai.cn/admin/index”
到此,可以得知是没有mkdir()
成功,结果因为没有权限,导致了请求失败,被拒绝。
那么,为什么nginx要访问
proxy_temp
文件夹呢?因为
proxy_temp
是nginx的缓存文件夹,我的css和js文件过大了,所以nginx一般会从缓存里面去拿,而不是每次都去原地址直接加载。
4、尝试解决
进入报错的路径,我的是 /usr/local/openresty/nginx/
,查看文件夹proxy_temp
权限。
cd /usr/local/openresty/nginx |
结果如下(注:这是改后的权限)
根据个人情况,给proxy_temp
文件夹重新修改权限和组 即可。
chown www root proxy_temp |
5、重启 nginx 服务
根据自己的nginx 服务配置来重启即可,命令可能如下:
./nginx -s reload |
我使用的是:
/etc/init.d/nginx reload |
6、重新刷新浏览器
完美,一切正常!
希望本文对你学习有所帮助,感谢您的阅读。
Recommend
-
36
This blog post is an in-depth look at an interesting logic bug class in the Windows Kernel and what I did to try to get it fixed with our partners at Microsoft. The maximum impact of the bug class is local privileg...
-
37
MySQL升级到8.0之后,PHP连接报错怎么解决? 作为资深的MySQL票友,最近我总在给8.0吹水,我们知数堂的MySQL课程去年也早就升级到8.0版本了。我的VPS老早就想升级了,无奈PHP版本太低,担心升级后有问题,所以一直没去折腾。这两天稍微得空,就开始折...
-
7
Problem After recovering WSUS or SCCM, Software-Updates will no longer install on SCCM Clients. In the UpdatesDeployment.log, you will get:'EnumerateUpdates for action (UpdateActionInstall) - Total actionable updates...
-
14
November 10, 2020 How To Fix Laravel CSRF Token Mismatch Error From AJAX RequestAs I’ve mentioned in pre...
-
9
Armin's Blogapt-get update Hash Sum Mismatch 的解决方法March 14, 2017最近在 docker 内使用 ubuntu 时经常发现 Hash Sum Mismatch 的问题,初步认为是运营商或 GFW 的问题,最快的解决方...
-
7
No child processes的解决办法 |坐而言不如起而行! 二丫讲梵 > 术业专攻 >
-
6
ipvsadm启动报错解决办法,另附ipvsadm详细参数 | 张戈博客Jager · 4月2日 · 2014年ipvsadm · lvs 4398次已读昨天在给老大做LVS演示时,手贱运行了一下 servic...
-
4
2021年03月25日 更新 openwrt 安装 netdata 出现 Package size mismatch 问题 解决办法 尝试增加 --force-checksum 选项(Ignore checksum mismatches) opkg --force-checksum install netdata
-
24
解决Linux系统中硬盘的GPT PMBR size mismatch will be corrected by write错误 今天用fdisk -l命令查看路由器中的3块硬盘时,发现下面这个错误: GPT PMBR size mismat...
-
4
windows 10 WSL安装linux子系统报错0x8007019e解决办法
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK