Skip to content

Commit 82f7633

Browse files
committed
update documentation
1 parent b161a24 commit 82f7633

File tree

4 files changed

+174
-17
lines changed

4 files changed

+174
-17
lines changed

db.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

source/_data/sidebar.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ en:
1717
Rewrite:
1818
Introduction: index.html
1919
Scope: scope.html
20-
Directive: directive.html
20+
Directives: directives.html
2121
Built-in Variables: built_in_variable.html
2222
api:
2323
Node.js API:

source/rewrite/directive.md renamed to source/rewrite/directives.md

Lines changed: 108 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ title: Rewrite Directive
77

88
`directive`(known as `command`)is for setting variable, or manipulating request/response.
99

10-
### set
10+
### Global Directives
11+
12+
#### * set
1113

1214
Description: define variables
1315

14-
Syntax: **set** key value
16+
Syntax:
17+
18+
> **set** key value
1519
1620
**Scope Chain**:global, domain, location
1721

@@ -21,7 +25,7 @@ Example:
2125
set $server hiipack;
2226
```
2327

24-
### Directives corrlative proxy request
28+
### Request Directives
2529

2630
The directives are `Request` instances to send request from proxy to target server.
2731

@@ -31,7 +35,9 @@ The directives are `Request` instances to send request from proxy to target serv
3135

3236
Description: setting a request header
3337

34-
Syntax: **proxy_set_header** key value
38+
Syntax:
39+
40+
> **proxy_set_header** key value
3541
3642
Example:
3743

@@ -43,7 +49,9 @@ proxy_set_header Host some.example.com;
4349

4450
Description: remove a request header
4551

46-
Syntax: **proxy_hide_header** key
52+
Syntax:
53+
54+
> **proxy_hide_header** key
4755
4856
Example:
4957

@@ -55,7 +63,9 @@ proxy_hide_header Host;
5563

5664
Description: setting a request cookie value
5765

58-
Syntax: **proxy_set_cookie** key value
66+
Syntax:
67+
68+
> **proxy_set_cookie** key value
5969
6070
Example:
6171

@@ -67,25 +77,99 @@ proxy_set_cookie from hiproxy;
6777

6878
Description: remove a request cookie value
6979

70-
Syntax: **proxy_hide_cookie** key
80+
Syntax:
81+
82+
> **proxy_hide_cookie** key
7183
7284
Example:
7385

7486
```bash
7587
proxy_hide_cookie from;
7688
```
7789

78-
### Directives correlative respose
90+
#### * proxy_method
91+
92+
Description: set the request method.
93+
94+
Syntax:
95+
96+
> **proxy_method** method
97+
98+
Example:
99+
100+
```bash
101+
proxy_method POST;
102+
```
103+
104+
#### * proxy_set_body
105+
106+
Description: set the request body content.
107+
108+
Syntax:
109+
110+
> **proxy_set_body** body
111+
112+
Example:
113+
114+
```bash
115+
proxy_set_body "a=1&b=2&c=3";
116+
```
117+
118+
#### * proxy_append_body
119+
120+
Description: append content to the body.
121+
122+
Syntax:
123+
124+
> **proxy_append_body** content
125+
126+
Example:
127+
128+
```bash
129+
proxy_append_body "&d=4";
130+
```
131+
132+
#### * proxy_replace_body
133+
134+
Description: replace part of the body.
135+
136+
Syntax:
137+
138+
> **proxy_replace_body** oldVal newVal
139+
140+
Example:
141+
142+
```bash
143+
proxy_replace_body "a=1" "a=111";
144+
```
145+
146+
### Response directives
79147

80148
The directives are `Response` instances to let proxy response the browser.
81149

82150
**Scope Chain**:domain, location
83151

152+
#### * status
153+
154+
Description: Set the response status code and status message.
155+
156+
Syntax:
157+
158+
> **status** statusCode statusMessage
159+
160+
Example:
161+
162+
```bash
163+
status 477 "Authentication failed";
164+
```
165+
84166
#### * set_header
85167

86168
Description: add a header
87169

88-
Syntax: **set_header** key value
170+
Syntax:
171+
172+
> **set_header** key value
89173
90174
Example:
91175

@@ -97,7 +181,9 @@ set_header SERVER hiproxy;
97181

98182
Description: remove a header
99183

100-
Syntax: **hide_header** key
184+
Syntax:
185+
186+
> **hide_header** key
101187
102188
*Example*:
103189

@@ -109,7 +195,9 @@ hide_header SERVER;
109195

110196
Description: set a coolie value
111197

112-
Syntax: **set_cookie** key value
198+
Syntax:
199+
200+
> **set_cookie** key value
113201
114202
Example
115203

@@ -121,7 +209,9 @@ set_cookie SESSION_ID 2BF36A09CB35FD71E;
121209

122210
Description: remove a cookie value
123211

124-
Syntax: **hide_cookie** key
212+
Syntax:
213+
214+
> **hide_cookie** key
125215
126216
*Example*:
127217

@@ -133,7 +223,9 @@ hide_cookie SESSION_ID;
133223

134224
Description: send the specified file as response
135225

136-
Syntax: **send_file** file_name
226+
Syntax:
227+
228+
> **send_file** file_name
137229
138230
Example:
139231

@@ -146,7 +238,9 @@ send_file /site/index.html;
146238

147239
Description: response specified content
148240

149-
Syntax: **echo** string
241+
Syntax:
242+
243+
> **echo** string
150244
151245
Example:
152246

source/zh-cn/rewrite/directive.md renamed to source/zh-cn/rewrite/directives.md

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ title: rewrite指令
99

1010
`指令`(也称:`命令`)用于设置变量,或者对request/response做一些操作。
1111

12-
### set
12+
### 全局指令
13+
14+
#### * set
1315

1416
描述:定义变量
1517

@@ -77,12 +79,73 @@ proxy_set_cookie from hiproxy;
7779
proxy_hide_cookie from;
7880
```
7981

82+
#### * proxy_method
83+
84+
描述:设置请求方法(GET、POST等)
85+
86+
语法: **proxy_method** method
87+
88+
示例:
89+
90+
```bash
91+
proxy_method POST;
92+
```
93+
94+
#### * proxy_set_body
95+
96+
描述:设置请求的body内容.
97+
98+
语法: **proxy_set_body** body
99+
100+
示例:
101+
102+
```bash
103+
proxy_set_body "a=1&b=2&c=3";
104+
```
105+
106+
#### * proxy_append_body
107+
108+
描述:向请求的body追加内容.
109+
110+
语法: **proxy_append_body** content
111+
112+
示例:
113+
114+
```bash
115+
proxy_append_body "&d=4";
116+
```
117+
118+
#### * proxy_replace_body
119+
120+
描述:替换body中的部分内容.
121+
122+
语法: **proxy_replace_body** oldVal newVal
123+
124+
示例:
125+
126+
```bash
127+
proxy_replace_body "a=1" "a=111";
128+
```
129+
130+
80131
### 代理响应相关指令
81132

82133
代理响应相关的指令用于配置代理服务器响应浏览器的`Response`对象。
83134

84135
**作用域链**:domain, location
85136

137+
#### * status
138+
139+
描述:设置相应状态码和消息
140+
141+
语法:**status** code message
142+
143+
例子:
144+
145+
```bash
146+
status 477 "Authentication failed";
147+
```
148+
86149
#### * set_header
87150

88151
描述:添加Header字段

0 commit comments

Comments
 (0)