@@ -719,6 +719,14 @@ ngx_http_modsecurity_save_headers_out(ngx_http_request_t *r)
719719upstream = r -> upstream ;
720720r -> upstream = & ngx_http_modsecurity_upstream ;
721721
722+ /* case SecServerSignature was used, the "Server: ..." header is added
723+ * here, overwriting the default header supplied by nginx.
724+ */
725+ if (modsecIsServerSignatureAvailale ()!= NULL ) {
726+ apr_table_add (ctx -> req -> headers_out ,"Server" ,
727+ modsecIsServerSignatureAvailale ());
728+ }
729+
722730if (apr_table_do (ngx_http_modsecurity_save_headers_out_visitor ,
723731r ,ctx -> req -> headers_out ,NULL )== 0 ) {
724732
@@ -1019,6 +1027,10 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
10191027return rc ;
10201028 }
10211029
1030+ if (modsecContextState (ctx -> req )== MODSEC_DISABLED ) {
1031+ return NGX_DECLINED ;
1032+ }
1033+
10221034if (r -> method == NGX_HTTP_POST
10231035&& modsecIsRequestBodyAccessEnabled (ctx -> req ) ) {
10241036
@@ -1074,8 +1086,6 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r) {
10741086ngx_http_modsecurity_ctx_t * ctx ;
10751087const char * location ;
10761088ngx_table_elt_t * h ;
1077- ngx_int_t rc ;
1078-
10791089
10801090cf = ngx_http_get_module_loc_conf (r ,ngx_http_modsecurity );
10811091ctx = ngx_http_get_module_ctx (r ,ngx_http_modsecurity );
@@ -1112,36 +1122,6 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r) {
11121122
11131123ngx_log_debug0 (NGX_LOG_DEBUG_HTTP ,r -> connection -> log ,0 ,"modSecurity: header filter" );
11141124
1115- /* header only or SecResponseBodyAccess off */
1116- if (r -> header_only || (!modsecIsResponseBodyAccessEnabled (ctx -> req )) ) {
1117-
1118- ctx -> complete = 1 ;
1119-
1120- if (ngx_http_modsecurity_load_headers_in (r )!= NGX_OK
1121- || ngx_http_modsecurity_load_headers_out (r )!= NGX_OK ) {
1122-
1123- return NGX_HTTP_INTERNAL_SERVER_ERROR ;
1124- }
1125-
1126- rc = ngx_http_modsecurity_status (r ,modsecProcessResponse (ctx -> req ));
1127-
1128- if (rc != NGX_DECLINED ) {
1129- return ngx_http_filter_finalize_request (r ,& ngx_http_modsecurity ,rc );
1130- }
1131-
1132- if (ngx_http_modsecurity_save_headers_in (r )!= NGX_OK
1133- || ngx_http_modsecurity_save_headers_out (r )!= NGX_OK ) {
1134- return ngx_http_filter_finalize_request (r ,& ngx_http_modsecurity ,NGX_HTTP_INTERNAL_SERVER_ERROR );
1135- }
1136-
1137- return ngx_http_next_header_filter (r );
1138- }
1139-
1140- /* SecResponseBodyAccess on, process rules in body filter */
1141-
1142- /* pretend we are ngx_http_header_filter */
1143- r -> header_sent = 1 ;
1144-
11451125r -> filter_need_in_memory = 1 ;
11461126return NGX_OK ;
11471127}