spacewander commented on code in PR #8564:
URL: https://github.com/apache/apisix/pull/8564#discussion_r1057461475


##########
apisix/plugins/proxy-rewrite.lua:
##########
@@ -297,6 +297,8 @@ do
         else
             ctx.var.upstream_uri = upstream_uri
         end
+    else
+        ctx.var.upstream_uri = upstream_uri

Review Comment:
   > To be quite honest, I don't know. _But_, a route to a GitLab API backend 
running at couple thousand requests/s has almost 50 percent error rate without 
this change because the request uri gets normalized _somewhere_ in the 
execution chain, even though it shouldn't be because 
`use_real_request_uri_unsafe` is set.
   > 
   > For instance 
`/api/v4/projects/12345/repository/files/technology%2Ftest.yaml?ref=stage` will 
be normalized down to 
`/api/v4/projects/12345/repository/files/technology/test.yaml?ref=stage` 
without this change, which shouldn't happen as this route has 
`use_real_request_uri_unsafe` enabled (which we did confirm).
   
   Interesting. AFAIK, the "missing" assignment here is intended.
   Because `upstream_uri` here is equal to `ctx.var.uri`:
   
https://github.com/ilteriseroglu-ty/apisix/blob/f6d05266852e8a46b8ef060e249c05c577a926f0/apisix/plugins/proxy-rewrite.lua#L263
   
   While `ctx.var.uri` is normalized (see 
http://nginx.org/en/docs/http/ngx_http_core_module.html#var_uri), assigning it 
to `ctx.var.upstream_uri` will break the `use_real_request_uri_unsafe`.
   
   Before use_real_request_uri_unsafe is added, we always assign `upstream_uri` 
to `ctx.var.upstream_uri`:
   
https://github.com/apache/apisix/blob/964a92ee773264999eb67d0cd5539baf8961001b/apisix/plugins/proxy-rewrite.lua#L171-L179
   
   That's why we don't assign it anymore when use_real_request_uri_unsafe is 
set.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to