背景:由于上传apk版本出现413的错误,同时报出跨域问题,但是测试环境没有出现该问题

原因:因为生产环境请求的接口是nginx反向代理时后的域名。测试环境没有配置nginx直接是ip+端口号请求。

解决方法:在ngixn.conf配置文件中添加 client_max_body_size属性值。

Syntax: client_max_body_size size;

client_max_body_size 1m;   (默认是1M)
Context: http, server, location
Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field.

If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client.

Please be aware that browsers cannot correctly display this error.

Setting size to 0 disables checking of client request body size.

可以选择在http{ }中设置:client_max_body_size   20m;

也可以选择在server{ }中设置:client_max_body_size   20m;

还可以选择在location{ }中设置:client_max_body_size   20m;

三者到区别是:http{} 中控制着所有nginx收到的请求。而报文大小限制设置在server{}中,则控制该server收到的请求报文大小,同理,如果配置在location中,则报文大小限制,只对匹配了location 路由规则的请求生效。

相关文章:

  • 2021-09-06
  • 2022-12-23
  • 2021-09-11
  • 2022-12-23
  • 2022-01-01
  • 2021-12-13
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-08-26
  • 2021-05-22
  • 2021-11-05
  • 2021-04-12
  • 2021-06-18
  • 2021-05-23
相关资源
相似解决方案