> ## Content Index
> Fetch the complete content index at: https://blog.hacking.pub/llms.txt
> Use this file to discover other available public pages before exploring further.

# 记一次openrestry问题
- URL: https://blog.hacking.pub/2018/11/15/ji-yi-ci-openrestrywen-ti/
- Published: 2018-11-15T13:21:08.000Z
- Updated: 2018-11-15T13:21:08.000Z
- Author: chainhelen

#### 背景

团队所做的微服务，统一签名校验是在openrestry(nginx)的lua脚本计算的  
突然有人报告了一个bug，当post请求body大于`10k`的时候，签名就会失效

#### 原因

在读取`body`参数时候，使用`ngx.req.get_body_data`

```
This function returns nil if

1. the request body has not been read,
2. the request body has been read into disk temporary files,
3. or the request body has zero size.

```

很明显是命中了第二条，body太大，会被存储到临时文件，此时需要使用`ngx.req.get_body_file`读取body

#### 解决

按照文档里面说的，强制使用内存读取`body`  
`To force in-memory request bodies, try setting client_body_buffer_size to the same size value in client_max_body_size.`