当前位置:首页 > nginx > 正文

nginx 上传文件大小配置(nginx请求参数大小)

  • nginx
  • 2024-03-24 20:57:10
  • 7528
Nginx 文件上传大小配置
nginx 使用 client_max_body_size 指令配置最大上传文件大小。
要素:
- client_max_body_size: 指定上传文件的最大字节数。
Example: client_max_body_size 10M;
允许上传最大为 10 MB 的文件。
- 单位:
- B:字节
- K:千字节 (1024 字节)
- M:兆字节 (1024 KB)
Example: client_max_body_size 500K;
允许上传最大为 500 KB 的文件。
- 作用域:
- server:整个服务器
- location:特定位置
Example: location /uploads { client_max_body_size 20M; }
仅在 /uploads 位置限制上传文件大小为 20 MB。
- 多个配置:
- 可以使用多个 client_max_body_size 指令,但较高限制会覆盖较低限制。
Example:
server {
client_max_body_size 10M;
location /uploads {
client_max_body_size 20M;
}
}
在该示例中,上传到 /uploads 位置的文件大小限制为 20 MB,而其他位置限制为 10 MB。