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


##########
apisix/cli/ngx_tpl.lua:
##########
@@ -677,8 +677,8 @@ http {
             if ($http_x_forwarded_for != "") {
                 set $var_x_forwarded_for "${http_x_forwarded_for}, 
${realip_remote_addr}";
             }
-            if ($http_x_forwarded_port != "") {
-                set $var_x_forwarded_port $http_x_forwarded_port;
+            if ($http_x_forwarded_host != "") {
+                set $var_x_forwarded_host $http_x_forwarded_host;

Review Comment:
   Do we need to add the removed directive back?



##########
apisix/cli/ngx_tpl.lua:
##########
@@ -69,10 +69,10 @@ lua {
 {% if enabled_stream_plugins["prometheus"] and not enable_http then %}
 http {
     lua_package_path  
"{*extra_lua_path*}$prefix/deps/share/lua/5.1/?.lua;$prefix/deps/share/lua/5.1/?/init.lua;]=]
-                       .. 
[=[{*apisix_lua_home*}/?.lua;{*apisix_lua_home*}/?/init.lua;;{*lua_path*};";
+    .. 
[=[{*apisix_lua_home*}/?.lua;{*apisix_lua_home*}/?/init.lua;;{*lua_path*};";

Review Comment:
   Could you disable the auto-format in your editor? This feature breaks a lot 
of indentations.



##########
apisix/init.lua:
##########
@@ -250,22 +243,22 @@ local function set_upstream_host(api_ctx, picked_server)
     api_ctx.var.upstream_host = picked_server.upstream_host
 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
-

Review Comment:
   Please keep the original blank lines



##########
t/plugin/proxy-rewrite2.t:
##########
@@ -207,3 +207,31 @@ X-Forwarded-Proto: http
 X-Forwarded-Proto: grpc
 --- response_headers
 X-Forwarded-Proto: http
+
+
+
+=== TEST 7: customize X-Forwarded-Port
+--- apisix_yaml
+routes:
+  -
+    id: 1
+    uri: /echo
+    plugins:
+        proxy-rewrite:
+            headers:
+                X-Forwarded-Port: 10080
+    upstream_id: 1
+upstreams:
+  -
+    id: 1
+    nodes:
+        "127.0.0.1:1980": 1
+    type: roundrobin
+#END
+--- request
+GET /echo
+--- more_headers
+X-Forwarded-Port: 8080
+--- response_headers
+X-Forwarded-Proto: 10080

Review Comment:
   ```suggestion
   X-Forwarded-Port: 10080
   ```



##########
apisix/init.lua:
##########
@@ -250,22 +243,22 @@ local function set_upstream_host(api_ctx, picked_server)
     api_ctx.var.upstream_host = picked_server.upstream_host
 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 port = api_ctx.var.http_x_forwarded_port
+    if port then
+        api_ctx.var.var_x_forwarded_port = port
+    end

Review Comment:
   Better to add a blank line between the `if end` blocks.



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