Skip to content

Commit 2e48ad8

Browse files
authored
Update README.md
1 parent ae9cb21 commit 2e48ad8

File tree

1 file changed

+27
-15
lines changed

1 file changed

+27
-15
lines changed

README.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,34 @@ For body filter before proxy to backend
88
Example:
99

1010
```nginx
11-
error_page 418 =200 /welcome_if_request_body;
12-
location /welcome_if_request_body {
13-
add_header Content-Type text/plain;
14-
return 200 "welcome_if_request_body, you hit it";
11+
http {
12+
....
13+
14+
map "$uri" $forward_status {
15+
default 100; # 100 means nothing return, continue to proxy phase
16+
"~*.+?\.(css|js|bmp|gif|ico|jpeg|jpg|pict|png|svg|swf|tif)$" 418;
1517
}
1618
17-
location = / {
18-
if_request_body on;
19-
return_status_if_body_eq "ASD" 418 on;
20-
return_status_if_body_eq "foo" 418;
21-
return_status_if_body_eq "john" 418;
22-
return_status_if_body_startswith "report" 418;
23-
return_status_if_body_contains "report" 418;
24-
return_status_if_body_regex "^[\d]+?abc" 418;
25-
proxy_pass http://localhost:7777;
26-
27-
}
19+
server {
20+
...
21+
error_page 418 =200 /welcome_if_request_body;
22+
location /welcome_if_request_body {
23+
add_header Content-Type text/plain;
24+
return 200 "welcome_if_request_body, you hit it";
25+
}
26+
27+
location = / {
28+
if_request_body on;
29+
return_status_if_body_eq "ASD" 418 on;
30+
return_status_if_body_eq "foo" 418;
31+
return_status_if_body_eq "john" 418;
32+
return_status_if_body_startswith "report" 418;
33+
return_status_if_body_contains "report" 418;
34+
return_status_if_body_regex "^[\d]+?abc" 418;
35+
proxy_pass http://localhost:7777;
2836
37+
}
38+
...
39+
}
40+
}
2941
```

0 commit comments

Comments
 (0)