ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
## 说明 nginx可以对用户的请求进行修改,这样在某些场景下是需要的; ## HTTP请求组成 1. 请求行; 只有第一行是请求行; ![](https://img.kancloud.cn/54/0b/540b22b85e1a334748095a812788e41c_1024x112.png) 2. 请求头; ![](https://img.kancloud.cn/1f/2e/1f2e11310a4975d0188633bbfc015878_3014x486.png) 3. 请求体; ![](https://img.kancloud.cn/9a/88/9a886c11cfee9a6838150b3ee4322533_1250x108.png) # 请求行修改指令 ## proxy_method 语法: ``` proxy_method method; ``` 默认值: ``` 无 ``` 上下文: ``` http | server | location ``` ## proxy_http_version 语法: ``` proxy_http_version 1.0 | 1.1; ``` 默认值: ``` proxy_http_version 1.0; ``` 上下文: ``` http | server | location ``` # 请求头修改指令 ## proxy_set_header 可以修改任意的头部信息; 语法: ``` proxy_set_header field value; ``` 默认值: ``` proxy_set_header Host $proxy_host; proxy_set_header Connection close; ``` 上下文: ``` http | server | location ``` ## proxy_pass_request_header 当使用on的时候客户端的所有请求头会原封不动的转发到上游服务器; 语法: ``` proxy_pass_request_header on | off; ``` 默认值: ``` proxy_pass_request_header on; ``` 上下文: ``` http | server | location ``` # 请求包体修改指令 ## proxy_set_body 语法: ``` proxy_set_body value; ``` 默认值: ``` 无 ``` 上下文: ``` http | server | location ``` ## proxy_pass_request_body 当使用on的时候客户端的包体会原封不动的转发到上游服务器; 语法: ``` proxy_pass_request_body on | off; ``` 默认值: ``` proxy_pass_request_body on; ``` 上下文: ``` http | server | location ```