• 004_Nginx 499错误的原因及解决方法


    一、

    今天进行系统维护,发现了大量的499错误,

    499错误

    ngx_string(ngx_http_error_495_page), /* 495, https certificate error */
    ngx_string(ngx_http_error_496_page), /* 496, https no certificate */
    ngx_string(ngx_http_error_497_page), /* 497, http to https */
    ngx_string(ngx_http_error_404_page), /* 498, canceled */
    ngx_null_string,                     /* 499, client has closed connection */

    可以看到,499对应的是 “client has closed connection”。这很有可能是因为服务器端处理的时间过长,客户端“不耐烦”了。

    Nginx 499错误的原因及解决方法
    打开Nginx的access.log发现在最后一次的提交是出现了HTTP1.1 499 0 -这样的错误,在百度搜索nginx 499错误,结果都是说客户端主动断开了连接。
    但经过我的测试这显然不是客户端的问题,因为使用端口+IP直接访问后端服务器不存在此问题,后来测试nginx发现如果两次提交post过快就会出现499的情况,看来是nginx认为是不安全的连接,主动拒绝了客户端的连接.

    但搜索相关问题一直找不到解决方法,最后终于在google上搜索到一英文论坛上有关于此错误的解决方法。

    proxy_ignore_client_abort on;

    Don’t know if this is safe.

    说要配置proxy_ignore_client_abort on;

    意思代理服务端不要主要主动关闭客户端连接。

    配置重启nginx,问题果然得到解决。只是安全方面稍有欠缺,但比总是出现找不到服务器好多了。

    也可参看其他案例:http://yucanghai.blog.51cto.com/5260262/1713803

    二、

    业务有一个下载Excel表格的需求,可以忍受很长的下载时间。由于开发对后端server的gc等还没有优化,业务又着急使用。因为apigateway有30s的超时时间限制。Nginx假如后端服务器端处理的时间过长,客户端“不耐烦”,Nginx就会在日志返回如下的499。

    (1)Nginx不加这个参数前的日志为

    10.600.254.35	10.600.254.35	2017-10-13T19:33:30+08:00	www.jyall.me^^11D9642583DF4E719736503E82DC4A3D|1507894380805	GET	499	/jyall/v1/minos/order/export?selectedFields=merchantId%2CmerchantName%2CpartnerOrderCode%2CtrackingId%2CserviceName%2CeffectivenessName%2CreceiverName%2CreceiverPrimaryPhone%2CreceiverCityName%2CreceiverAddress%2CreceiverLocation%2CorderWeight%2CtransportName%2CtransportAddress%2CcarrierLocation%2CtransportTel%2CcomplaintStatus%2CcomplaintDescription%2CdeliveryCost%2CtimeExtraCost%2CdistanceExtraCost%2CweatherExtraCost%2CweightExtraCost%2CtotalDeliveryCost%2CdiscountCost%2CtotalFee%2CorderAddTime%2CrequireReceiveTime%2CapolloOrderCreateTime%2CdispatchTime%2CtakeMealTime%2CtoStoreTime%2CstartDeliveryTime%2CarrivalDateTime%2CdeliveriedTime%2CagentId%2CagentName%2CstationId%2CcarrierTeamName%2CcarrierDriverName%2CcarrierDriverPhone%2CorderStatusName%2CdeliveryDistance%2CorderTimeout%2CabnormalDesc%2CtrackingRemark%2CmajorBusiness&startCreatedAt=1507824000000&endCreatedAt=1507910340000
    

    proxy_ignore_client_abort on; #让Nginx代理服务端不要主动关闭客户端的连接。

    (2)加上这个参数后去掉限制后,nginx不再返回499,而是200了

    10.600.254.35	10.600.254.35	2017-10-13T19:38:49+08:00	jyall-admin.jyall.com^^78882C98800A47E8A7D1EA9CD1A2C190|1507894686022	GET	200	/jyall/v1/minos/order/export?selectedFields=merchantId%2CmerchantName%2CpartnerOrderCode%2CtrackingId%2CserviceName%2CeffectivenessName%2CreceiverName%2CreceiverPrimaryPhone%2CreceiverCityName%2CreceiverAddress%2CreceiverLocation%2CorderWeight%2CtransportName%2CtransportAddress%2CcarrierLocation%2CtransportTel%2CcomplaintStatus%2CcomplaintDescription%2CdeliveryCost%2CtimeExtraCost%2CdistanceExtraCost%2CweatherExtraCost%2CweightExtraCost%2CtotalDeliveryCost%2CdiscountCost%2CtotalFee%2CorderAddTime%2CrequireReceiveTime%2CapolloOrderCreateTime%2CdispatchTime%2CtakeMealTime%2CtoStoreTime%2CstartDeliveryTime%2CarrivalDateTime%2CdeliveriedTime%2CagentId%2CagentName%2CstationId%2CcarrierTeamName%2CcarrierDriverName%2CcarrierDriverPhone%2CorderStatusName%2CdeliveryDistance%2CorderTimeout%2CabnormalDesc%2CtrackingRemark%2CmajorBusiness&startCreatedAt=1507824000000&endCreatedAt=1507910340000	HTTP	HTTP/1.1	43.735	43.735	2229	32768	211088	10.200.62.152:8080	-application/vnd.ms-excel;charset=utf-8	application/vnd.ms-excel;charset=utf-8	jyall-admin.jyall.com	apirouter	user	al	al-channel-statble-1	APIRouter	1.0	bj-jyall-web-1	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36	-
    

      

     

  • 相关阅读:
    maven(一 基本操作 命令 标签)
    springmvc学习(五)
    springmvc学习(四)
    springmvc学习(三)
    springmvc学习(二)
    一个简单的springmvc例子 入门(1)
    第一次记录
    字符设备驱动(六)按键poll机制
    字符设备驱动(五)按键优化休眠
    字符设备驱动(四)按键中断
  • 原文地址:https://www.cnblogs.com/itcomputer/p/7237415.html
Copyright © 2020-2023  润新知