@@ -8,22 +8,34 @@ For body filter before proxy to backend
8
8
Example:
9
9
10
10
``` 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;
15
17
}
16
18
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;
28
36
37
+ }
38
+ ...
39
+ }
40
+ }
29
41
```
0 commit comments