报错分析
本地运行的项目,进行上传图片功能没问题;但是,在部署项目中,上传选中超过1M的图片就上传失败,怀疑和nginx有关。
查看docker中nginx的log文件,发现如下内容:
2024/06/14 07:28:44 [error] 30#30: *232 client intended to send too large body: 5526337 bytes, client: x.x.x.xx, server: localhost, request: "POST /prod-api/common/upload HTTP/1.1", host: "10.10.2.35:8108", referrer: http://x.x.x.x:8108/content/service
解决方法
在ngingx配置文件中加如下内容。
**client_max_body_size 20M; # 设置最大请求体大小为 20MB**
修改完重新再运行docker compose即可。再次上传图片就会成功了。