Skip to content

Commit 9ad8d64

Browse files
authored
Hook into Nginx NGX_HTTP_ACCESS_PHASE instead of NGX_HTTP_PREACCESS_PHASE
1 parent fd28e6a commit 9ad8d64

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ if test -n "$ngx_module_link"; then
117117
ngx_module_type=HTTP_FILTER
118118
ngx_module_name="$ngx_addon_name"
119119
ngx_module_srcs="$ngx_addon_dir/src/ngx_http_modsecurity_module.c \
120-
$ngx_addon_dir/src/ngx_http_modsecurity_pre_access.c \
120+
$ngx_addon_dir/src/ngx_http_modsecurity_access.c \
121121
$ngx_addon_dir/src/ngx_http_modsecurity_header_filter.c \
122122
$ngx_addon_dir/src/ngx_http_modsecurity_body_filter.c \
123123
$ngx_addon_dir/src/ngx_http_modsecurity_log.c \
@@ -148,7 +148,7 @@ else
148148
NGX_ADDON_SRCS="\
149149
$NGX_ADDON_SRCS \
150150
$ngx_addon_dir/src/ngx_http_modsecurity_module.c \
151-
$ngx_addon_dir/src/ngx_http_modsecurity_pre_access.c \
151+
$ngx_addon_dir/src/ngx_http_modsecurity_access.c \
152152
$ngx_addon_dir/src/ngx_http_modsecurity_header_filter.c \
153153
$ngx_addon_dir/src/ngx_http_modsecurity_body_filter.c \
154154
$ngx_addon_dir/src/ngx_http_modsecurity_log.c \

src/ngx_http_modsecurity_pre_access.c renamed to src/ngx_http_modsecurity_access.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ ngx_http_modsecurity_request_read(ngx_http_request_t *r)
4343

4444

4545
ngx_int_t
46-
ngx_http_modsecurity_pre_access_handler(ngx_http_request_t *r)
46+
ngx_http_modsecurity_access_handler(ngx_http_request_t *r)
4747
{
4848
#if 1
4949
ngx_pool_t *old_pool;
5050
ngx_http_modsecurity_ctx_t *ctx;
5151
ngx_http_modsecurity_conf_t *mcf;
5252

53-
dd("catching a new _preaccess_ phase handler");
53+
dd("catching a new _access_ phase handler");
5454

5555
mcf = ngx_http_get_module_loc_conf(r, ngx_http_modsecurity_module);
5656
if (mcf == NULL || mcf->enable != 1)

src/ngx_http_modsecurity_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,8 @@ int ngx_http_modsecurity_store_ctx_header(ngx_http_request_t *r, ngx_str_t *name
165165
void ngx_http_modsecurity_log(void *log, const void* data);
166166
ngx_int_t ngx_http_modsecurity_log_handler(ngx_http_request_t *r);
167167

168-
/* ngx_http_modsecurity_pre_access.c */
169-
ngx_int_t ngx_http_modsecurity_pre_access_handler(ngx_http_request_t *r);
168+
/* ngx_http_modsecurity_access.c */
169+
ngx_int_t ngx_http_modsecurity_access_handler(ngx_http_request_t *r);
170170

171171
/* ngx_http_modsecurity_rewrite.c */
172172
ngx_int_t ngx_http_modsecurity_rewrite_handler(ngx_http_request_t *r);

src/ngx_http_modsecurity_module.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ static ngx_int_t
552552
ngx_http_modsecurity_init(ngx_conf_t *cf)
553553
{
554554
ngx_http_handler_pt *h_rewrite;
555-
ngx_http_handler_pt *h_preaccess;
555+
ngx_http_handler_pt *h_access;
556556
ngx_http_handler_pt *h_log;
557557
ngx_http_core_main_conf_t *cmcf;
558558
int rc = 0;
@@ -582,18 +582,18 @@ ngx_http_modsecurity_init(ngx_conf_t *cf)
582582

583583
/**
584584
*
585-
* Processing the request body on the preaccess phase.
585+
* Processing the request body on the access phase.
586586
*
587587
* TODO: check if hook into separated phases is the best thing to do.
588588
*
589589
*/
590-
h_preaccess = ngx_array_push(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers);
591-
if (h_preaccess == NULL)
590+
h_access = ngx_array_push(&cmcf->phases[NGX_HTTP_CCESS_PHASE].handlers);
591+
if (h_access == NULL)
592592
{
593-
dd("Not able to create a new NGX_HTTP_PREACCESS_PHASE handle");
593+
dd("Not able to create a new NGX_HTTP_ACCESS_PHASE handle");
594594
return NGX_ERROR;
595595
}
596-
*h_preaccess = ngx_http_modsecurity_pre_access_handler;
596+
*h_access = ngx_http_modsecurity_access_handler;
597597

598598
/**
599599
* Process the log phase.

0 commit comments

Comments
 (0)