@@ -22,7 +22,7 @@ use Test::Nginx;
22
22
select STDERR ; $| = 1;
23
23
select STDOUT ; $| = 1;
24
24
25
- my $t = Test::Nginx-> new()-> has(qw/ http auth_request/ );
25
+ my $t = Test::Nginx-> new()-> has(qw/ http proxy auth_request/ );
26
26
27
27
$t -> write_file_expand(' nginx.conf' , <<'EOF' );
28
28
49
49
SecRequestBodyAccess On
50
50
SecRule REQUEST_BODY "@rx BAD BODY" "id:11,phase:request,deny,log,status:403"
51
51
';
52
- proxy_pass http://127.0.0.1:8081 ;
52
+ proxy_pass http://127.0.0.1:%%PORT_8081%% ;
53
53
}
54
54
55
55
location /nobodyaccess {
59
59
SecRule REQUEST_BODY "@rx BAD BODY" "id:21,phase:request,deny,log,status:403"
60
60
SecRule ARGS_POST|ARGS_POST_NAMES "@rx BAD ARG" "id:22,phase:request,deny,log,status:403"
61
61
';
62
- proxy_pass http://127.0.0.1:8081 ;
62
+ proxy_pass http://127.0.0.1:%%PORT_8081%% ;
63
63
}
64
64
65
65
location /bodylimitreject {
@@ -70,7 +70,12 @@ http {
70
70
SecRequestBodyLimitAction Reject
71
71
SecRule REQUEST_BODY "@rx BAD BODY" "id:31,phase:request,deny,log,status:403"
72
72
';
73
- proxy_pass http://127.0.0.1:8081;
73
+ proxy_pass http://127.0.0.1:%%PORT_8081%%;
74
+ }
75
+
76
+ location /bodylimitrejectserver {
77
+ modsecurity off;
78
+ proxy_pass http://127.0.0.1:%%PORT_8082%%;
74
79
}
75
80
76
81
location /bodylimitprocesspartial {
81
86
SecRequestBodyLimitAction ProcessPartial
82
87
SecRule REQUEST_BODY "@rx BAD BODY" "id:41,phase:request,deny,log,status:403"
83
88
';
84
- proxy_pass http://127.0.0.1:8081 ;
89
+ proxy_pass http://127.0.0.1:%%PORT_8081%% ;
85
90
}
86
91
87
92
location = /auth {
@@ -95,7 +100,22 @@ http {
95
100
SecRequestBodyAccess On
96
101
';
97
102
auth_request /auth;
98
- proxy_pass http://127.0.0.1:8081;
103
+ proxy_pass http://127.0.0.1:%%PORT_8081%%;
104
+ }
105
+ }
106
+
107
+ server {
108
+ listen 127.0.0.1:%%PORT_8082%%;
109
+ modsecurity on;
110
+ modsecurity_rules '
111
+ SecRuleEngine On
112
+ SecRequestBodyAccess On
113
+ SecRequestBodyLimit 128
114
+ SecRequestBodyLimitAction Reject
115
+ SecRule REQUEST_BODY "@rx BAD BODY" "id:31,phase:request,deny,log,status:403"
116
+ ';
117
+ location / {
118
+ proxy_pass http://127.0.0.1:%%PORT_8081%%;
99
119
}
100
120
}
101
121
}
104
124
$t -> run_daemon(\&http_daemon);
105
125
$t -> run()-> waitforsocket(' 127.0.0.1:' . port(8081));
106
126
107
- $t -> plan(36 );
127
+ $t -> plan(40 );
108
128
109
129
# ##############################################################################
110
130
@@ -146,6 +166,14 @@ like(
146
166
' POST with auth_request (request size < client_header_buffer_size), no preread'
147
167
);
148
168
169
+ TODO: {
170
+ local $TODO = ' not yet' ;
171
+
172
+ foreach my $method ((' GET' , ' POST' , ' PUT' , ' DELETE' )) {
173
+ like(http_req_body($method , ' /bodylimitrejectserver' , ' BODY' x 33 ), qr / 403 Forbidden/ , " $method request body limit reject, block (inherited SecRequestBodyLimit)" );
174
+ }
175
+ }
176
+
149
177
# ##############################################################################
150
178
151
179
sub http_daemon {
0 commit comments