spacewander commented on a change in pull request #5367: URL: https://github.com/apache/apisix/pull/5367#discussion_r743330688
########## 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: The same feature is implemented in your PR, except for the X-Forwarded-For one. After your change, there won't be client IP appending to the http_x_forwarded_for when the header is not rewritten. We should add test for it and fix it. -- 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