网站首页 > 技术教程 正文
转载自:https://www.cnblogs.com/tinywan/p/6777592.html
(1)错误页面显示
错误日志:
// :: [error] #: * recv() failed (: Connection reset by peer) reading response header upstream,
client: ., server: live.baidu.com, request: , upstream: show.baidu.com, host:
复制代码
复制代码
复制代码
复制代码
复制代码
复制代码
./ -Real--Real--Forwarded-
复制代码
复制代码
IP地址和域名对应关系:
show.baidu.com (172.16.0.166)
live.baidu.com (192.168.1.166)
经过各种百度和google都说是后端服务器的原因,但是访问后端服务器也是正常的show.baidu.com (172.16.0.166),但是当访问关于一个和Redis有关的页面的时候就会出现,redis服务器已经断开连接,重启Redis服务器后正常工作
(3)总结:如果当前服务器是代理服务器,出现502的错误原因,则一般都是后端服务器的异常导致的
三、nginx错误日志文件Error.log常见错误详细说明
我们经常遇到各种各样的nginx错误日志,平时根据一些nginx错误日志就可以分析出原因了。不过不是很系统,这里网上看到一篇资料还是比较系统的关于nginx的error.log的详细说明,这里记录下,方便以后查看了解。
以上表格来自网络资料。这里只是记录下,方便以后查看。
四、Nginx错误日志说明
错误日志类型
- 类型1: upstream timed out
- 类型2: connect() failed
- 类型3: no live upstreams
- 类型4: upstream prematurely closed connection
- 类型5: 104: Connection reset by peer
- 类型6: client intended to send too large body
- 类型7: upstream sent no valid HTTP/1.0 header
类型
错误日志
原因
解决办法
1 upstream timed out (110: Connection timed out) while connecting to upstream nginx与upstream建立tcp连接超时,nginx默认连接建立超时为200ms 排查upstream是否能正常建立tcp连接 1 upstream timed out (110: Connection timed out) while reading response header from upstream nginx从upstream读取响应时超时,nginx默认的读超时为20s,读超时不是整体读的时间超时,而是指两次读操作之间的超时,整体读耗时有可能超过20s 排查upstream响应请求为什么过于缓慢 2 connect() failed (104: Connection reset by peer) while connecting to upstream nginx与upstream建立tcp连接时被reset 排查upstream是否能正常建立tcp连接 2 connect() failed (111: Connection refused) while connecting to upstream nginx与upstream建立tcp连接时被拒 排查upstream是否能正常建立tcp连接 4 upstream prematurely closed connection nginx在与upstream建立完tcp连接之后,试图发送请求或者读取响应时,连接被upstream强制关闭 排查upstream程序是否异常,是否能正常处理http请求 5 recv() failed (104: Connection reset by peer) while reading response header from upstream nginx从upstream读取响应时连接被对方reset 排查upstream应用已经tcp连接状态是否异常 6 client intended to send too large body 客户端试图发送过大的请求body,nginx默认最大允许的大小为1m,超过此大小,客户端会受到http 413错误码
- 调整请求客户端的请求body大小;
- 调大相关域名的nginx配置:client_max_body_size;
7 upstream sent no valid HTTP/1.0 header nginx不能正常解析从upstream返回来的请求行
=====================openresty 遇到的错误信息
复制代码
复制代码
*
复制代码
复制代码
======================
在Nginx配置文件的的http段,加入下面的配置
32
重启Nginx错误依旧。再在host配置的php段加入下面配置
4
重启Nginx 服务器即可
er
复制代码
复制代码
摘要: 近日,为了让更新后台业务系统时,不影响线上用户的使用终止,故使用了nginx+tomcat集群,其中用到了memcached-session-manager组件来集中管理session,确实遇到了各种“坑”,这几天有时间陆续会把各种坑挖出来,记录一下已被忘记。 -----第一篇--nginx监听端口非80时的转发问题
复制代码
复制代码
复制代码
复制代码
///.:-Real--Forwarded-
复制代码
复制代码
以上是nginx默认监听端口号为80的情况,由于公司系统是内网应用,用户已经将链接收藏起来了,收藏后的地址是之前的单台tomcat的8080端口,为了不影响他们的操作习惯所以决定让nginx继续监听8080端口,保持对外端口相同。
于是乎,我便想当然的把nginx的端口号改成了8080,把tomcat的端口改为了8081。改后的nginx配置如下:
复制代码
复制代码
///.:-Real--Forwarded-
复制代码
复制代码
改完之后,重启测试发现问题了:
当访问http://localhost:8080后,浏览器自动跳转到了 http://localhost去了
这是为什么呢?????
原来,如果nginx的监听端口不是默认的80端口,改为其他非80端口后,后端服务tomcat中的request.getServerPort()方法无法获得正确的端口号,仍然返回到80端口。在response.sendRedirect()时,客户端可能无法获得正确的重定向URL。
所以正确的配置:
复制代码
复制代码
///.:-Real--Forwarded-
复制代码
复制代码
安装报错:
make[]: Entering directory `/usr/include/opensslmake[]: *** No rule to make target `clean make[]: Leaving directory `/usr/include/opensslmake[]: *** [/usr/include/openssl//openssl/include/openssl/ssl.h] Error ]: Leaving directory `/jowei/nginx-.make: *** [build] Error
出现这个问题决绝办法:将你编译代命了也就是 with-openssl=/______这个路径指向你的源码安装包路径而
–with-pcre Nginx的rewrite功能需要使用pcre库才能工作,而Nginx的编译参数里面的这个选项并不是像常规的那样指定pcre的安装目录,而是指定pcre源代码的目录。
也就是说,如果你的系统路径下已经可以找到pcre的lib和include文件,这个选项可以不指定了。如果你的系统没有安装pcre,那么就指定该选项,Nginx会在编译的时候从你指定的这个目录把pcre编译进来。
把pcre编译进来。
========20170516 视频直播遇到的问题==================
// :: [alert] #: * socket() failed connecting to upstream,
client: ., server: 333.111.com, request: ,
upstream: ,
host: ,
referrer:
// :: [crit] #: * open() failed (,
client: ., server: 333.11.com, request:
upstream: "http://127.0.1.4:80/live/10.ts",
host: "2.24.87.6:8081",
referrer: "http://y.com/live/12"
referrer: "http://y.com/live/12"
// :: [crit] #: * open() failed reading upstream,
可以使用’ulimit’命令来查看系统文件限制
ulimit -Hn ulimit -Sn
(1)/etc/security/limits.conf
# End of * soft nofile * hard nofile
(2)/etc/sysctl.conf
【1】1核512M
复制代码
复制代码
vm.swappiness = ==== == = = = = = = =
复制代码
复制代码
【2】4核4G
复制代码
复制代码
vm.swappiness = ==== == = = = ==== = = = = = =
复制代码
复制代码
复制代码
复制代码
www@iZ23o0b38gsZ:~$ ulimit - size (blocks, -c) --e) size (blocks, --i) -l) --n) bytes, -p) -q) - priority (-r) -s) (seconds, --u) - locks (-x) unlimited
复制代码
复制代码
(1)/etc/security/limits.conf 是空的
本地服务器信息查看
www@ubuntu5:/opt/openresty/nginx/logs$ ulimit -/opt/openresty/nginx/logs$ ulimit -
(2)/etc/sysctl.conf 也是空的
(3)ulimit -a
复制代码
复制代码
core size (blocks, -c) --e) size (blocks, --i) -l) --n) bytes, -p) -q) - priority (-r) -s) (seconds, --u) - locks (-x) unlimited
复制代码
复制代码
参考文献1:http://www.drupal001.com/2013/07/nginx-open-files-error/
参考文献2:Nginx 出現 500 Error 修復 (too many open file, connection)
参考文献3:ulimit -a详解
参考文献4:Linux上修改open files数目
ulimit -a
阿里云4核4G
复制代码
复制代码
www@iZ23o0b38gsZ:~$ ulimit - size (blocks, -c) --e) size (blocks, --i) -l) --n) bytes, -p) -q) - priority (-r) -s) (seconds, --u) - locks (-x) unlimited
复制代码
复制代码
阿里云1核512M
复制代码
复制代码
root@iZ23nl9zsjyZ:~# ulimit - size (blocks, -c) --e) size (blocks, --i) -l) --n) bytes, -p) -q) - priority (-r) -s) (seconds, --u) - locks (-x) unlimited
复制代码
复制代码
请对比以上数据做出自己的优化方式
# End of * soft nofile * hard nofile
复制代码
复制代码
vm.swappiness = ==== == = = = ==== = = = = = =
复制代码
复制代码
[3]这个只是针对当前客户
ulimit -n >>/etc//etc/profile #加载修改后的profile
查看系统句柄文件数
当前系统文件句柄的最大数目,只用于查看,不能设置修改
cat /proc/sys/fs/file-max
查看进程打开文件数
如果需要查看所有进程的文件打开数,如下图命令lsof |wc -l
猜你喜欢
- 2024-09-28 Nginx 安装 Naxsi 模块实现 WAF WEB应用安全防火墙的功能
- 2024-09-28 Linux环境通过Dockerfile创建Nginx镜像
- 2024-09-28 你可能忽略的macOS下brew安装nginx细节解读,干货
- 2024-09-28 centos7安装fastdfs集群+nginx1.18(生产环境)
- 2024-09-28 linux安装nginx(linux安装软件的三种方式)
- 2024-09-28 linux安装nginx,实现nginx负载均衡,图片服务器
- 2024-09-28 大数据离线项目实践之nginx服务器搭建
- 2024-09-28 Nginx静态服务器与负载均衡配置(nginx静态资源配置)
- 2024-09-28 离线项目实践之nginx服务器搭建(nginx离线安装与配置详解)
- 2024-09-28 安装Nginx的几种方式(nginx安装与配置详解)
你 发表评论:
欢迎- 最近发表
-
- Win10 TH2正式版官方ESD映像转换ISO镜像方法详解
- 使用iso镜像升级到Windows 10的步骤
- macOS Ventura 13.2 (22D49) Boot ISO 原版可引导镜像
- 安利一个用ISO镜像文件制作引导U盘的的小工具RUFUS
- CentOS 7使用ISO镜像配置本地yum源
- 用于x86平台的安卓9.0 ISO镜像发布下载:通吃I/A/N、完全免费
- AlmaLinux 9.6发布:升级工具、初步支持IBM Power虚拟化技术
- Rufus写入工具简洁介绍与教程(写入模式)
- 新硬件也能安装使用了,Edge版Linux Mint 21.3镜像发布
- 开源工程师:Ubuntu应该抛弃32位ISO镜像
- 标签列表
-
- 下划线是什么 (87)
- 精美网站 (58)
- qq登录界面 (90)
- nginx 命令 (82)
- nginx .http (73)
- nginx lua (70)
- nginx 重定向 (68)
- Nginx超时 (65)
- nginx 监控 (57)
- odbc (59)
- rar密码破解工具 (62)
- annotation (71)
- 红黑树 (57)
- 智力题 (62)
- php空间申请 (61)
- 按键精灵 注册码 (69)
- 软件测试报告 (59)
- ntcreatefile (64)
- 闪动文字 (56)
- guid (66)
- abap (63)
- mpeg 2 (65)
- column (63)
- dreamweaver教程 (57)
- excel行列转换 (56)
本文暂时没有评论,来添加一个吧(●'◡'●)