本文作者:DurkBlue

Nginx服务413 Request Entity Too Large

Nginx服务413 Request Entity Too Large摘要: Nginx服务器上运行基于SrpingBoot的WebApi服务(服务端已设置最大可上传50M),通过前端上传一个超过10M的文件,出现以下提示:原因分析查看Nginx 关于cli...

Nginx服务器上运行基于SrpingBoot的WebApi服务(服务端已设置最大可上传50M),通过前端上传一个超过10M的文件,出现以下提示:



原因分析

查看Nginx 关于client_max_body_size的描述

http服务客户端最大上传默认设置为1M


Syntax: client_max_body_size size;

Default: client_max_body_size 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.


解决办法

修改nginx.conf配置文件,增加client_max_body_size大小。

http {

 ...

 # set client body size to 50M #

    client_max_body_size 50m;


    include             /etc/nginx/mime.types;

    default_type        application/octet-stream;


    ...

    }


测试

上传13M的文档


上传成功

此篇文章由DurkBlue博客申请发布,转载吧请注明来处
文章投稿或转载声明

来源:DurkBlue版权归原作者所有,转载请保留出处。本站文章发布于 2022-02-21
温馨提示:文章内容系作者个人观点,不代表DurkBlue博客对其观点赞同或支持。

赞(0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

阅读
分享

发表评论取消回复

快捷回复:
AddoilApplauseBadlaughBombCoffeeFabulousFacepalmFecesFrownHeyhaInsidiousKeepFightingNoProbPigHeadShockedSinistersmileSlapSocialSweatTolaughWatermelonWittyWowYeahYellowdog

评论列表 (暂无评论,1360人围观)参与讨论

还没有评论,来说两句吧...