Nginx 413 Request Entity Too Large error solution

Preface

In use today ngnix do web server when uploading files report 413 Request Entity Too Largeerrors, specifically in the following figure:
Insert picture description here

Analysis and solution

This is because nginxthere is a limit to the size of the uploaded file, the default is 1M .

When it exceeds the size, it will report 413 (too large) error. At this time we need to modify the parameters of nginx client_max_body_size 20M;

Change to the maximum upload size we allow, such as 20M.

Open the main nginx configuration file nginx.conf, generally in the location of /usr/local/nginx/conf/nginx.conf, find the http{} section, modify or add

client_max_body_size 20M;

After changing the configuration, restart Nginx;

./nginx -s reload;

Configuration file

The reference configuration is as follows:

user  root;
worker_processes  1;
 
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;
 
events {
    
    
    worker_connections  1024;
}
 
http {
    
    
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    client_max_body_size 20M;# 参考参考参考
}

Guess you like

Origin blog.csdn.net/abu935009066/article/details/112463346