Skip to content

Commit ce21d6b

Browse files
defanatorFelipe Zimmerle
authored andcommitted
Explicitly set log object to r->connection->log in preaccess phase handler.
This change fixes a number of scenarios when ModSecurity's log entries may be written to the wrong file descriptors. In particular, there was an issue with almost any configuration using nginx cache features (proxy_cache, fastcgi_cache, etc) when garbage from ModSecurity logs has been sent to the control socket used for communication between nginx master process and auxiliary processes (workers, cache manager, cache loader). Described behavior was observed with nginx/1.7.0, modsecurity/2.8.0 and OWASP CRS v2.2.9.
1 parent 0276b34 commit ce21d6b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

nginx/modsecurity/ngx_http_modsecurity.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,8 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r) {
11431143
ngx_http_modsecurity_ctx_t *ctx = NULL;
11441144
ngx_http_modsecurity_loc_conf_t *cf = NULL;
11451145

1146+
modsecSetLogHook(r->connection->log, modsecLog);
1147+
11461148
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
11471149
"ModSec: Catching a new access phase handler. Count: %d",
11481150
r->main->count);

0 commit comments

Comments
 (0)