Nginx 上传文件过大的问题

文件上传过大被nginx拦截的问题解决

花了半小时最近了个上传文件的功能,有效的解决了qq收作业,各种消息轰炸的局面,但是针对一些上传文件过大的内容,nginx会限制报错,例如充满图片的ppt。

出现错误:

2020/05/21 15:27:58 [error] 1701#1701: *26 client intended to send too large body: 10998982 bytes, client:

主要是由于上传文件过大导致的问题。

解决方案:

只需要修改nginx种上传文件body的最大限度就行了。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

http {
##
# Basic Settings
##
# 默认请求报文的最大限量
client_max_body_size 20M;
# 下载应用时需要off
sendfile on;

tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;

# server_names_hash_bucket_size 64;
# server_name_in_redirect off;

# 包含的类型
include /etc/nginx/mime.types;

说明: 只要添加client_max_body_size 20M; 这行就可以了。

最后,重启nginx服务器。