问题
发送post请求出现报错:
<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.23.2</center>
</body>
</html>
原因
nginx有客户端请求体大小限制,默认是:1M,而我发送的POST请求中上传的文件大小有9M,所以被nginx拦截,并报错:413 Request Entity Too Large
解决
修改nginx.conf
配置,在接口代理中增加client_max_body_size 100M;
,可以根据自己的需要,将client_max_body_size
的值设置大些。最后,再重启nginx
服务即可。
# nginx.conf
user root;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
server {
listen 80;
server_name your.domain.com;
root /usr/share/nginx/files;
charset utf-8;
location / {
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
client_max_body_size 100M;
}
}
}