Opened 2 years ago

Closed 2 years ago

Last modified 6 weeks ago

#2402 closed defect (invalid)

Not right to skip location rewrite phase for server null location.

Reported by: akf00000@… Owned by:
Priority: minor Milestone:
Component: documentation Version: 1.19.x
Keywords: Cc:
uname -a: Linux localhost.localdomain 3.10.0-1160.el7.x86_64
nginx -V: nginx version: nginx/1.21.7
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
built with OpenSSL 1.1.1 (compatible; BoringSSL) (running with BoringSSL)
TLS SNI support enabled

Description (last modified by akf00000@…)

Not right to skip location rewrite phase for server null location or not match any location.
In function ngx_http_rewrite_handler, the contidion to skip is not right.
we should change it like this:

@@ -147,7 +147,7 @@ ngx_http_rewrite_handler(ngx_http_request_t *r)
     cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
     index = cmcf->phase_engine.location_rewrite_index;
 
-    if (r->phase_handler == index && r->loc_conf == cscf->ctx->loc_conf) {
+    if (r->phase_handler >= index && r->loc_conf == cscf->ctx->loc_conf) {
         /* skipping location rewrite phase for server null location */
         return NGX_DECLINED;
     }

Change History (4)

comment:1 by akf00000@…, 2 years ago

Description: modified (diff)

comment:2 by akf00000@…, 2 years ago

Description: modified (diff)

comment:3 by Maxim Dounin, 2 years ago

The condition looks perfectly correct for me, and it does exactly what advertised: it skips processing of the server rewrites in location rewrite phase, since these are handled in the server rewrite phase. If you think the condition isn't correct for some reason, you may want to elaborate more on why do you think it is incorrect, why your condition is better, and which problem you are trying to solve.

Note well that Trac is generally a bad place for development-related discussions. Consider using the nginx-devel@ mailing list instead.

comment:4 by Maxim Dounin, 2 years ago

Resolution: invalid
Status: newclosed

Feedback timeout.

Note: See TracTickets for help on using tickets.