Nginx 上传文件超出大小限制,提示 413 Request Entity Too Large

Yami
2026年1月11日
34

Nginx 上传文件超出大小限制,提示 413 Request Entity Too Large

增加 client_max_body_size 100M; 根据需求调整大小(如100MB)

全局生效(http 块):
http {
    client_max_body_size 100M;
}
单个站点生效(server 块):
server {
    listen 80;
    server_name example.com;
    client_max_body_size 100M;
}

检查配置语法是否正确

nginx -t

重新加载配置(不中断服务)

nginx -s reload

或直接重启服务

systemctl restart nginx

增加 client_max_body_size 100M; 根据需求调整大小(如100MB)

全局生效(http 块):
http {
    client_max_body_size 100M;
}
单个站点生效(server 块):
server {
    listen 80;
    server_name example.com;
    client_max_body_size 100M;
}

检查配置语法是否正确

nginx -t

重新加载配置(不中断服务)

nginx -s reload

或直接重启服务

systemctl restart nginx

加载中...