1. 问题说明
- 环境:前端使用
vue
+axios
,后端使用python
+flask
,使用nginx
进行转发请求 - 问题:单独使用前端加后端,没出现任何问题;加入
nginx
后,能接收到options
请求,但是真正的请求被拦截了
2. 问题排查
查看nginx错误日志
tail /var/log/nginx/error.log
.......
2020/10/28 11:40:41 [error] 26213#26213: *30497 client intended to send too large body: 7168281 bytes, client: 192.168.1.2, server: _, request: "POST /upload/tower?v=0.7358503685426334 HTTP/1.1", host: "127.0.0.1:8888", referrer: "http://127.0.0.1:8080/"
2020/10/28 11:41:01 [error] 26213#26213: *30501 client intended to send too large body: 7374452 bytes, client: 192.168.1.2, server: _, request: "POST /upload/tower?v=0.38792314655415794 HTTP/1.1", host: "127.0.0.1:8888", referrer: "http://127.0.0.1:8080/"
......
3. 问题解决
nginx
中有一个默认参数用来设置上传大小限制,默认大小是1M
需要自己在对应的location中添加client_max_body_size
参数进行修改
500m
表示最大上传500M
,该参数自行设计
location / {
.......
client_max_body_size 500m;
}