spacewander commented on a change in pull request #5367:
URL: https://github.com/apache/apisix/pull/5367#discussion_r741566964



##########
File path: apisix/init.lua
##########
@@ -266,12 +266,21 @@ local function set_upstream_host(api_ctx, picked_server)
 end
 
 
+local upstream_proxy_headers = {
+    var_x_forwarded_proto = 'X-Forwarded-Proto',
+    var_x_forwarded_for = 'X-Forwarded-For',

Review comment:
       For X-Forwarded-For, we need to append the client's real-ip to it, see 
https://github.com/apache/apisix/blob/a0efeca194bcca58e62d73c0a19464f480a1b7c9/t/APISIX.pm#L698

##########
File path: apisix/init.lua
##########
@@ -266,12 +266,21 @@ local function set_upstream_host(api_ctx, picked_server)
 end
 
 
+local upstream_proxy_headers = {
+    var_x_forwarded_proto = 'X-Forwarded-Proto',
+    var_x_forwarded_for = 'X-Forwarded-For',
+    var_x_forwarded_host = 'X-Forwarded-Host',
+    var_x_forwarded_port = 'X-Forwarded-Port',
+}
+
 local function set_upstream_headers(api_ctx, picked_server)
     set_upstream_host(api_ctx, picked_server)
 
-    local hdr = core.request.header(api_ctx, "X-Forwarded-Proto")
-    if hdr then
-        api_ctx.var.var_x_forwarded_proto = hdr
+    for ngx_key, hdr_key in pairs(upstream_proxy_headers) do

Review comment:
       We can also remove 
https://github.com/apache/apisix/blob/a0efeca194bcca58e62d73c0a19464f480a1b7c9/apisix/cli/ngx_tpl.lua#L600
 and 
https://github.com/apache/apisix/blob/a0efeca194bcca58e62d73c0a19464f480a1b7c9/t/APISIX.pm#L697




-- 
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