SkyeYoung commented on code in PR #12551:
URL: https://github.com/apache/apisix/pull/12551#discussion_r2309382550


##########
apisix/init.lua:
##########
@@ -290,21 +293,6 @@ end
 
 local function set_upstream_headers(api_ctx, picked_server)
     set_upstream_host(api_ctx, picked_server)
-
-    local proto = api_ctx.var.http_x_forwarded_proto
-    if proto then
-        api_ctx.var.var_x_forwarded_proto = proto
-    end
-
-    local x_forwarded_host = api_ctx.var.http_x_forwarded_host
-    if x_forwarded_host then
-        api_ctx.var.var_x_forwarded_host = x_forwarded_host
-    end
-
-    local port = api_ctx.var.http_x_forwarded_port
-    if port then
-        api_ctx.var.var_x_forwarded_port = port
-    end

Review Comment:
   
https://github.com/apache/apisix/blob/09f6e3682c5da1437f951273200d44cc18b13a28/apisix/plugins/ai.lua#L277-L282
   
   Because the code above will replace `handle_upstream` with `ai_upstream` 
below:
   
   
https://github.com/apache/apisix/blob/09f6e3682c5da1437f951273200d44cc18b13a28/apisix/plugins/ai.lua#L115-L117
   
   This leads to the failure of this part of the code.
   
   Now that we need to handle `X-Forwarded-*`, we need to update these 
`var_x_forwarded_*`, so we need to extract this part of the code as 
`update_var_x_forwarded_headers`.
   
   
https://github.com/apache/apisix/blob/3260931f301f741d5551af895cbfd6b12d1aff31/apisix/cli/ngx_tpl.lua#L835-L837



-- 
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: notifications-unsubscr...@apisix.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to