@@ -40,7 +40,7 @@ static ngx_command_t ngx_http_redirectionio_commands[] = {
40
40
{
41
41
ngx_string ("redirectionio_project_key" ),
42
42
NGX_HTTP_MAIN_CONF |NGX_HTTP_SRV_CONF |NGX_HTTP_SIF_CONF |NGX_HTTP_LOC_CONF |NGX_HTTP_LIF_CONF |NGX_CONF_TAKE1 ,
43
- ngx_conf_set_str_slot ,
43
+ ngx_http_set_complex_value_slot ,
44
44
NGX_HTTP_LOC_CONF_OFFSET ,
45
45
offsetof(ngx_http_redirectionio_conf_t , project_key ),
46
46
NULL
@@ -72,11 +72,19 @@ static ngx_command_t ngx_http_redirectionio_commands[] = {
72
72
{
73
73
ngx_string ("redirectionio_scheme" ),
74
74
NGX_HTTP_MAIN_CONF |NGX_HTTP_SRV_CONF |NGX_HTTP_SIF_CONF |NGX_HTTP_LOC_CONF |NGX_HTTP_LIF_CONF |NGX_CONF_TAKE1 ,
75
- ngx_conf_set_str_slot ,
75
+ ngx_http_set_complex_value_slot ,
76
76
NGX_HTTP_LOC_CONF_OFFSET ,
77
77
offsetof(ngx_http_redirectionio_conf_t , scheme ),
78
78
NULL
79
79
},
80
+ {
81
+ ngx_string ("redirectionio_host" ),
82
+ NGX_HTTP_MAIN_CONF |NGX_HTTP_SRV_CONF |NGX_HTTP_SIF_CONF |NGX_HTTP_LOC_CONF |NGX_HTTP_LIF_CONF |NGX_CONF_TAKE1 ,
83
+ ngx_http_set_complex_value_slot ,
84
+ NGX_HTTP_LOC_CONF_OFFSET ,
85
+ offsetof(ngx_http_redirectionio_conf_t , host ),
86
+ NULL
87
+ },
80
88
ngx_null_command /* command termination */
81
89
};
82
90
@@ -198,6 +206,21 @@ static ngx_int_t ngx_http_redirectionio_create_ctx_handler(ngx_http_request_t *r
198
206
ctx -> wait_for_connection = 0 ;
199
207
ctx -> last_buffer_sent = 0 ;
200
208
ctx -> read_handler = ngx_http_redirectionio_read_dummy_handler ;
209
+ ctx -> project_key .len = 0 ;
210
+ ctx -> scheme .len = 0 ;
211
+ ctx -> host .len = 0 ;
212
+
213
+ if (ngx_http_complex_value (r , conf -> project_key , & ctx -> project_key ) != NGX_OK ) {
214
+ return NGX_DECLINED ;
215
+ }
216
+
217
+ if (conf -> scheme != NULL && ngx_http_complex_value (r , conf -> scheme , & ctx -> scheme ) != NGX_OK ) {
218
+ return NGX_DECLINED ;
219
+ }
220
+
221
+ if (conf -> host != NULL && ngx_http_complex_value (r , conf -> host , & ctx -> host ) != NGX_OK ) {
222
+ return NGX_DECLINED ;
223
+ }
201
224
202
225
ngx_http_set_ctx (r , ctx , ngx_http_redirectionio_module );
203
226
@@ -329,7 +352,7 @@ static ngx_int_t ngx_http_redirectionio_log_handler(ngx_http_request_t *r) {
329
352
return NGX_DECLINED ;
330
353
}
331
354
332
- log = ngx_http_redirectionio_protocol_create_log (r , ctx , & conf -> project_key );
355
+ log = ngx_http_redirectionio_protocol_create_log (r , ctx , & ctx -> project_key );
333
356
334
357
if (log == NULL ) {
335
358
return NGX_DECLINED ;
@@ -363,8 +386,18 @@ static char *ngx_http_redirectionio_merge_conf(ngx_conf_t *cf, void *parent, voi
363
386
364
387
ngx_conf_merge_uint_value (conf -> enable_logs , prev -> enable_logs , NGX_HTTP_REDIRECTIONIO_ON );
365
388
ngx_conf_merge_uint_value (conf -> show_rule_ids , prev -> show_rule_ids , NGX_HTTP_REDIRECTIONIO_OFF );
366
- ngx_conf_merge_str_value (conf -> project_key , prev -> project_key , "" );
367
- ngx_conf_merge_str_value (conf -> scheme , prev -> scheme , "" );
389
+
390
+ if (conf -> project_key == NULL ) {
391
+ conf -> project_key = prev -> project_key ;
392
+ }
393
+
394
+ if (conf -> scheme == NULL ) {
395
+ conf -> scheme = prev -> scheme ;
396
+ }
397
+
398
+ if (conf -> host == NULL ) {
399
+ conf -> host = prev -> host ;
400
+ }
368
401
369
402
if (conf -> pass .url .data == NULL ) {
370
403
if (prev -> pass .url .data ) {
@@ -413,7 +446,7 @@ static char *ngx_http_redirectionio_merge_conf(ngx_conf_t *cf, void *parent, voi
413
446
}
414
447
}
415
448
416
- if (conf -> project_key . len > 0 ) {
449
+ if (conf -> project_key != NULL ) {
417
450
ngx_conf_merge_uint_value (conf -> enable , prev -> enable , NGX_HTTP_REDIRECTIONIO_ON );
418
451
} else {
419
452
ngx_conf_merge_uint_value (conf -> enable , prev -> enable , NGX_HTTP_REDIRECTIONIO_OFF );
@@ -456,17 +489,15 @@ static void ngx_http_redirectionio_write_match_action_handler(ngx_event_t *wev)
456
489
ngx_http_redirectionio_ctx_t * ctx ;
457
490
ngx_connection_t * c ;
458
491
ngx_http_request_t * r ;
459
- ngx_http_redirectionio_conf_t * conf ;
460
492
461
493
c = wev -> data ;
462
494
r = c -> data ;
463
495
ctx = ngx_http_get_module_ctx (r , ngx_http_redirectionio_module );
464
- conf = ngx_http_get_module_loc_conf (r , ngx_http_redirectionio_module );
465
496
466
497
ngx_add_timer (c -> read , RIO_TIMEOUT );
467
498
ctx -> read_handler = ngx_http_redirectionio_read_match_action_handler ;
468
499
469
- ngx_http_redirectionio_protocol_send_match (c , r , ctx , & conf -> project_key );
500
+ ngx_http_redirectionio_protocol_send_match (c , r , ctx , & ctx -> project_key );
470
501
}
471
502
472
503
static void ngx_http_redirectionio_read_match_action_handler (ngx_event_t * rev , const char * action_serialized ) {
0 commit comments