一、

1、线上有个域名出现一个访问报错:

413 Payload Too Large

这里贴一下关于这个报错的解释:

The 413 (Payload Too Large) status code indicates that the server is
   refusing to process a request because the request payload is larger
   than the server is willing or able to process.  The server MAY close
   the connection to prevent the client from continuing the request.

If the condition is temporary, the server SHOULD generate a
   Retry-After header field to indicate that it is temporary and after
   what time the client MAY try again.

于是条件反射就去改nginx的配置,在相应的server段或location段添加client_max_body_size 100m;然后reload  nginx,发现问题并没有解决。还是报错。

有google了一番,找到关于413 Payload Too Large的解释,发现应该是后端server的问题,就开始去排查后端的服务:

,发现:

Error:request entity too large

https://github.com/expressjs/body-parser#limit

应该是baody-parser,的问题:

bodyParser.json([options])

limit

Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the bytes library for parsing. Defaults to '100kb'

默认 json  limit的大小100k,我们的json已经130k了,很明显就找到问题所在了。

接下来就是修改:

app.use( bodyParser.json({limit: '50mb'}) );
app.use(bodyParser.urlencoded({
  limit: '50mb',
  extended: true,
  parameterLimit:50000
}));

2、如果报错为413  request  entity  too large
就应该是nginx的问题了,就需要改nginx的配置,在相应的server段或location段添加client_max_body_size 100m;然后reload  nginx

二、

1、记一次nginx的resolver的坑,修改了dns的地址后,执行了nginx -s reload发现并没有生效。配置如下:

resolver 10.2.3.4;

upstream grpcservers {
server saturn-core.service.hq:50051;
}

server {
listen 9000 http2;
# server_name localhost;
access_log /var/log/nginx/grpc.log main;
error_log /var/log/nginx/grpc_error.log;
location / {
grpc_pass grpc://grpcservers;
}
}

nginx  reload不会使dns重新解析,而是使用dns缓存,只有等到dns的TTL到期后,才会重新解析。简单粗暴的解决方案直接重启nginx,而不要使用reload。

其他解决方案也不尽完美,还有比较看好的使用模块ngx_upstream_jdomain,在http配置域中配置DNS服务器,在upstream中按照这个模块的格式配置,支持设置每隔多少秒进行一次解析。interval可指定解析间隔,如果解析失败则使用缓存中的上一次解析结果的IP地址访问。

http {

resolver   10.2.3.4 ;

upstream  grpcserver {

jdomain  saturn-conre.service.hq:9000 interval=10; #指定域名和端口,每隔10秒进行一次解析

}

server {

listen       9000 http2;

client_body_buffer_size 10m;

server_name  localhost;

location / {

grpc_pass      grpc://grpcserver;

}

}

缺点:DNS服务器只能在http配域中全局配置,并且现有的nginx编译的时候默认并没有将这个模块编译进去,使用这个功能需要重新编译。



nginx报错整理的更多相关文章

  1. Windows下nginx报错解决:CreateFile() "xxx/logs/nginx.pid" failed

    写在前面 本文给出Windows下nginx报错:CreateFile() "xxx/logs/nginx.pid" failed 的解决方法并分析了出错原因,其中 xxx 表示n ...

  2. nginx 报错 upstream timed out (110: Connection timed out)解决方案【转】

    转自 nginx 报错 upstream timed out (110: Connection timed out)解决方案 - 为程序员服务http://outofmemory.cn/code-sn ...

  3. nginx报错:./configure: error: C compiler cc is not found, gcc 是已经安装了的

    源码安装nginx报错,找不到gcc,但是实际上gcc是存在的,如下: # ./configure checking for OS + Linux -.el7.x86_64 x86_64 checki ...

  4. nginx报错zero size shared memory zone one

    为了限速,在虚拟主机中加上了一个参数:limit_conn one 1:结果导致重启nginx报错: zero size shared memory zone "one"解决办法是 ...

  5. nginx报错:403 Forbidden 并且访问首页index.php是下载文件的状态

    nginx报错:403 Forbidden 并且访问首页index.php是下载文件的状态,不能正常解析php 系统有其他两个站访问是正常的 看日志没有看到明显的错误 搜索了下: 答案如下: php的 ...

  6. Centos下yum安装Nginx报错 No package nginx available.

    在Centos6下使用yum安装Nginx报错 解决方案: yum install epel-release

  7. 安装Nginx报错“Cannot retrieve metalink for repository: epel. Please verify its path and try again”

    CentOS 6.5中通过yum安装nginx报错. 搜了一下,很多都是修改某个配置文件的.但是在StackOverFlow的某个问题下,有人回答说修改配置文件并不是一个好的方法,虽然我采用了这个人的 ...

  8. nginx报错:nginx: [emerg] unknown directive in /etc/nginx/conf.d/test.conf:4

    nginx报错:nginx: [emerg] unknown directive  in /etc/nginx/conf.d/test.conf:4 解决: 第四行出现了 tab 空格 , 换成正常的 ...

  9. nginx报错 nginx: [alert] kill(25903, 1) failed (3: No such process)

    当nginx 中报错 时 nginx报错 nginx: [alert] kill(25903, 1) failed (3: No such process) 通过在nginx/sbin,目录下 运行命 ...

随机推荐

  1. java的并发和多线程

    本文主要讲解Java并发相关的内容,包括锁.信号量.堵塞队列.线程池等主要内容. 并发的优点和缺点 在讲述怎么利用多线程的情况下,我们先看一下采用多线程并发的优缺点. 优点 提高资源利用率 如读取一个 ...

  2. hdu 4964 恶心模拟

    http://acm.hdu.edu.cn/showproblem.php?pid=4964 给定语句,按照语法翻译html并输出. 就是恶心的模拟,递归搞就行了 处理id和class时,在一个'&g ...

  3. MODBUS串行通信协议详细说明

    第一章  简介 本文详细地描述了装置在MODBUS 通讯模式下的输入和输出命令.信息和数据,以便第三方使用和开发. 1.1 串行通讯协议的目的 通信协议的作用是使信息和数据在上位机主站和装置之间有效地 ...

  4. [mysql] mysql 查询语句收集

    // 1. 筛选出当天的中奖名单            $where = " date_format(f_ctime,'%Y-%m-%d') = current_date()"; ...

  5. Android-Recyclerview的简单使用

    由于Recyclerview是在 android.support.v7.widget.包 RecyclerView,所以需要导Recycler库: 导Recycler库: 选择项目,右键-->  ...

  6. PSP个人项目耗时对比记录表:四则运算

    Personal Software Process Stages Time(%) 计划 5    •估计这个任务需要多长时间 5 开发 60    •需求分析  5    •生成设计文档  5     ...

  7. Lily-一个埋点管理工具

    本文来自网易云社区 前言 在很多项目中,埋点数据使用表格来统计的,随着项目的进行,数据量越来越复杂,越来越难以维护.所以很多公司都已经开发了一整套系统,从埋点的录入到代码的输出. 我们项目中iOS和A ...

  8. Android--------------BroadcastReceiver的学习

    一.广播的注册方式 发送广播: Intent mIntent = new Intent("com.simware.BroadcastReceiverDemo"); mIntent. ...

  9. C#6.0语言规范(十一) 结构

    结构与类类似,因为它们表示可以包含数据成员和函数成员的数据结构.但是,与类不同,结构是值类型,不需要堆分配.结构类型的变量直接包含结构的数据,而类类型的变量包含对数据的引用,后者称为对象. 结构对于具 ...

  10. Xshell 配色方案

    [wsp] text=cOc0c0 cyan(bold)=50ebfc text(bold)=9999e8 magenta=7b5175 green=008000 green(bold)=1cc470 ...