diff --git a/attachments/nginx/ngx_module/ngx_cp_hook_threads.c b/attachments/nginx/ngx_module/ngx_cp_hook_threads.c index 8f332fe..6cfb03c 100644 --- a/attachments/nginx/ngx_module/ngx_cp_hook_threads.c +++ b/attachments/nginx/ngx_module/ngx_cp_hook_threads.c @@ -223,7 +223,8 @@ ngx_http_cp_req_header_handler_thread(void *_ctx) &(request->headers_in.headers.part), REQUEST_HEADER, session_data_p->session_id, - &num_messages_sent + &num_messages_sent, + &ctx->waf_tag ); if (send_header_result != NGX_OK) { write_dbg( @@ -412,7 +413,8 @@ ngx_http_cp_res_header_filter_thread(void *_ctx) &request->headers_out.headers.part, RESPONSE_HEADER, session_data_p->session_id, - &num_messages_sent + &num_messages_sent, + &ctx->waf_tag ); if (send_header_result != NGX_OK) { write_dbg( diff --git a/attachments/nginx/ngx_module/ngx_cp_hooks.c b/attachments/nginx/ngx_module/ngx_cp_hooks.c index 9141f3d..b47c61b 100644 --- a/attachments/nginx/ngx_module/ngx_cp_hooks.c +++ b/attachments/nginx/ngx_module/ngx_cp_hooks.c @@ -412,6 +412,7 @@ ngx_http_cp_req_header_handler(ngx_http_request_t *request) int res; static int is_failure_state_initialized = 0; static int is_metric_data_initialized = 0; + ngx_cp_attachment_conf_t *conf; clock_gettime(CLOCK_REALTIME, &hook_time_begin); diff --git a/attachments/nginx/ngx_module/ngx_cp_io.h b/attachments/nginx/ngx_module/ngx_cp_io.h index 6a0ef17..071bf30 100644 --- a/attachments/nginx/ngx_module/ngx_cp_io.h +++ b/attachments/nginx/ngx_module/ngx_cp_io.h @@ -138,6 +138,7 @@ ngx_http_cp_content_length_sender( /// - #RESPONSE_HEADER /// @param[in] cur_request_id Request session's Id. /// @param[in, out] num_messages_sent Number of messages sent will be saved onto this parameter. +/// @param[in, out] waf_tag WAF tag to be sent. /// @returns ngx_int_t /// - #NGX_OK /// - #NGX_ERROR @@ -147,7 +148,8 @@ ngx_http_cp_header_sender( ngx_list_part_t *headers, ngx_http_chunk_type_e header_type, uint32_t cur_request_id, - ngx_uint_t *num_messages_sent + ngx_uint_t *num_messages_sent, + ngx_str_t *waf_tag ); /// diff --git a/attachments/nginx/ngx_module/ngx_http_cp_attachment_module.c b/attachments/nginx/ngx_module/ngx_http_cp_attachment_module.c index 7fc2083..6239f93 100644 --- a/attachments/nginx/ngx_module/ngx_http_cp_attachment_module.c +++ b/attachments/nginx/ngx_module/ngx_http_cp_attachment_module.c @@ -30,6 +30,7 @@ typedef struct { ngx_flag_t enable; ///< Flags if the configuration enabled. ngx_int_t num_of_workers; ///< Number of workers. ngx_uint_t current_loc_config_version; ///< NGINX configuration version. + ngx_str_t waf_tag; ///< WAF tag value for the location block. } ngx_cp_attachment_conf_t; /// @@ -120,6 +121,14 @@ static ngx_command_t ngx_cp_attachment_commands[] = { offsetof(ngx_cp_attachment_conf_t, num_of_workers), NULL }, + { + ngx_string("waf_tag"), + NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, + ngx_conf_set_str_slot, + NGX_HTTP_LOC_CONF_OFFSET, + offsetof(ngx_cp_attachment_conf_t, waf_tag), + NULL + }, ngx_null_command }; @@ -210,6 +219,7 @@ ngx_cp_attachment_create_conf(ngx_conf_t *conf) module_conf->enable = NGX_CONF_UNSET; module_conf->num_of_workers = 0; module_conf->current_loc_config_version = current_config_version; + ngx_str_null(&module_conf->waf_tag); write_dbg(DBG_LEVEL_TRACE, "Successfully created attachment module configuration"); return module_conf; } @@ -270,6 +280,7 @@ ngx_cp_attachment_merge_conf(ngx_conf_t *configure, void *curr, void *next) ngx_conf_merge_value(conf->enable, prev->enable, NGX_CONF_UNSET); ngx_conf_merge_value(conf->num_of_workers, prev->num_of_workers, ngx_ncpu); + ngx_conf_merge_str_value(conf->waf_tag, prev->waf_tag, ""); write_dbg(DBG_LEVEL_TRACE, "Successfully set attachment module configuration in nginx configuration chain"); return NGX_CONF_OK;