Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

经验分享-解决Ngxin和Node环境下 Runtime Error : 413,request entity too large #62

Open
sunmaobin opened this issue Mar 21, 2019 · 0 comments

Comments

@sunmaobin
Copy link
Owner

commented Mar 21, 2019

背景

我们服务端使用Nginx+Node(Express v4.15.2)部署,今天遇到Post参数过长时请求报错:

Runtime Error : 413,request entity too large

为什么会过长呢?因为有一个变态的需求,就是需要将图片读出来BASE64作为参数传递,所以...

解决

  • 修改Nginx配置,一般路径如下:
vi /etc/nginx/conf.d/default.conf

在路由接口上增加2个参数,如下:

location /api/ {
       client_max_body_size 0;
       proxy_buffering off;
       proxy_pass http://localhost:8000/;
}

然后reload一下Ngxin的服务:

/usr/sbin/nginx -s reload
  • 修改Express服务中,app.js 文件,修改2个参数,如下(假如参数限制50M):
app.use(bodyParser.json({limit: "50mb"}));
app.use(bodyParser.urlencoded({limit: "50mb", extended: true, parameterLimit:50000}));

@sunmaobin sunmaobin added this to the 2019年 milestone Mar 21, 2019

@sunmaobin sunmaobin self-assigned this Mar 21, 2019

@sunmaobin sunmaobin changed the title 经验分享:解决Ngxin和Node环境下 Runtime Error : 413,request entity too large 经验分享-解决Ngxin和Node环境下 Runtime Error : 413,request entity too large Apr 17, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.