11
11
#endif
12
12
#include "../inc/ngx_http_waf_module_check.h"
13
13
14
- static ngx_int_t ngx_waf_mult_mount = 0 ;
15
-
16
14
static ngx_command_t ngx_http_waf_commands [] = {
17
15
18
16
{
19
17
ngx_string ("waf_mult_mount" ),
20
- NGX_HTTP_MAIN_CONF | NGX_CONF_FLAG ,
18
+ NGX_HTTP_SRV_CONF | NGX_CONF_FLAG ,
21
19
ngx_http_waf_mult_mount ,
22
- NGX_HTTP_MAIN_CONF_OFFSET ,
23
- offsetof(ngx_http_waf_main_conf_t , waf_mult_mount ),
20
+ NGX_HTTP_SRV_CONF_OFFSET ,
21
+ offsetof(ngx_http_waf_srv_conf_t , waf_mult_mount ),
24
22
NULL
25
23
},
26
24
{
@@ -62,7 +60,7 @@ static ngx_command_t ngx_http_waf_commands[] = {
62
60
static ngx_http_module_t ngx_http_waf_module_ctx = {
63
61
NULL ,
64
62
ngx_http_waf_init_after_load_config ,
65
- ngx_http_waf_create_main_conf ,
63
+ NULL ,
66
64
NULL ,
67
65
ngx_http_waf_create_srv_conf ,
68
66
NULL ,
@@ -88,11 +86,9 @@ ngx_module_t ngx_http_waf_module = {
88
86
89
87
90
88
static char * ngx_http_waf_mult_mount (ngx_conf_t * cf , ngx_command_t * cmd , void * conf ) {
91
- ngx_http_waf_main_conf_t * main_conf = conf ;
92
89
if (ngx_conf_set_flag_slot (cf , cmd , conf ) != NGX_CONF_OK ) {
93
90
return NGX_CONF_ERROR ;
94
91
}
95
- ngx_waf_mult_mount = main_conf -> waf_mult_mount ;
96
92
return NGX_CONF_OK ;
97
93
}
98
94
@@ -154,17 +150,6 @@ static char* ngx_http_waf_cc_deny_limit_conf(ngx_conf_t* cf, ngx_command_t* cmd,
154
150
}
155
151
156
152
157
- static void * ngx_http_waf_create_main_conf (ngx_conf_t * cf ) {
158
- ngx_http_waf_main_conf_t * main_conf = NULL ;
159
- main_conf = ngx_pcalloc (cf -> pool , sizeof (ngx_http_waf_main_conf_t ));
160
- if (main_conf == NULL ) {
161
- return NULL ;
162
- }
163
- main_conf -> waf_mult_mount = NGX_CONF_UNSET ;
164
- return main_conf ;
165
- }
166
-
167
-
168
153
static void * ngx_http_waf_create_srv_conf (ngx_conf_t * cf ) {
169
154
ngx_http_waf_srv_conf_t * srv_conf = NULL ;
170
155
srv_conf = ngx_pcalloc (cf -> pool , sizeof (ngx_http_waf_srv_conf_t ));
@@ -176,6 +161,7 @@ static void* ngx_http_waf_create_srv_conf(ngx_conf_t* cf) {
176
161
srv_conf -> ngx_pool = ngx_create_pool (sizeof (ngx_pool_t ) + INITIAL_SIZE , srv_conf -> ngx_log );
177
162
srv_conf -> alloc_times = 0 ;
178
163
srv_conf -> waf = NGX_CONF_UNSET ;
164
+ srv_conf -> waf_mult_mount = NGX_CONF_UNSET ;
179
165
srv_conf -> waf_cc_deny = NGX_CONF_UNSET ;
180
166
srv_conf -> waf_cc_deny_limit = NGX_CONF_UNSET ;
181
167
srv_conf -> waf_cc_deny_duration = NGX_CONF_UNSET ;
@@ -220,10 +206,8 @@ static ngx_int_t ngx_http_waf_init_after_load_config(ngx_conf_t* cf) {
220
206
}
221
207
* h = ngx_http_waf_handler_ip_url_referer_ua_args_cookie_post ;
222
208
223
- if (ngx_waf_mult_mount != 0 ) {
224
- h = ngx_array_push (& cmcf -> phases [NGX_HTTP_SERVER_REWRITE_PHASE ].handlers );
225
- * h = ngx_http_waf_handler_url_args ;
226
- }
209
+ h = ngx_array_push (& cmcf -> phases [NGX_HTTP_SERVER_REWRITE_PHASE ].handlers );
210
+ * h = ngx_http_waf_handler_url_args ;
227
211
228
212
ngx_str_t waf_blocked_name = ngx_string ("waf_blocked" );
229
213
ngx_http_variable_t * waf_blocked = ngx_http_add_variable (cf , & waf_blocked_name , NGX_HTTP_VAR_NOCACHEABLE );
@@ -356,6 +340,9 @@ static ngx_int_t ngx_http_waf_handler_url_args(ngx_http_request_t* r) {
356
340
if (srv_conf -> waf == 0 || srv_conf -> waf == NGX_CONF_UNSET ) {
357
341
http_status = NGX_DECLINED ;
358
342
}
343
+ else if (srv_conf -> waf_mult_mount == 0 || srv_conf -> waf_mult_mount == NGX_CONF_UNSET ) {
344
+ http_status = NGX_DECLINED ;
345
+ }
359
346
else if (!(r -> method & (NGX_HTTP_GET | NGX_HTTP_POST ))) {
360
347
http_status = NGX_DECLINED ;
361
348
}
@@ -422,6 +409,9 @@ static ngx_int_t ngx_http_waf_handler_ip_url_referer_ua_args_cookie_post(ngx_htt
422
409
if (srv_conf -> waf == 0 || srv_conf -> waf == NGX_CONF_UNSET ) {
423
410
http_status = NGX_DECLINED ;
424
411
}
412
+ else if (srv_conf -> waf_mult_mount == 0 || srv_conf -> waf_mult_mount == NGX_CONF_UNSET ) {
413
+ http_status = NGX_DECLINED ;
414
+ }
425
415
else if (!(r -> method & (NGX_HTTP_GET | NGX_HTTP_POST ))) {
426
416
http_status = NGX_DECLINED ;
427
417
}
0 commit comments