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



##########
File path: t/lib/server.lua
##########
@@ -531,6 +531,11 @@ function _M.plugin_proxy_rewrite_resp_header()
     ngx.say(s)
 end
 
+function _M.server_upstream_host()

Review comment:
       There is no need to add a new backend. `/uri` already contains the host: 
https://github.com/apache/apisix/blob/530fb4d62c990ec23026f43f70b878e157d441bc/t/node/upstream.t#L510

##########
File path: t/node/upstream.t
##########
@@ -510,3 +510,54 @@ GET /uri
 qr/host: localhost/
 --- error_log
 proxy request to 127.0.0.1:1980
+
+
+
+=== TEST 21: check that including port in host header is supported when 
pass_host = node and port is not standard
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "methods": ["GET"],
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "uri": "/server_upstream_host"
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1979": 1,
+                                "127.0.0.1:1980": 1000
+                            },
+                            "type": "roundrobin",
+                            "pass_host": "node"
+                        },
+                        "uri": "/hello"

Review comment:
       We can use `"/uri"` directly, as the test I pointed out before

##########
File path: t/node/upstream.t
##########
@@ -510,3 +510,54 @@ GET /uri
 qr/host: localhost/
 --- error_log
 proxy request to 127.0.0.1:1980
+
+
+
+=== TEST 21: check that including port in host header is supported when 
pass_host = node and port is not standard
+--- config
+    location /t {
+        content_by_lua_block {
+            local t = require("lib.test_admin").test
+            local code, body = t('/apisix/admin/routes/1',
+                 ngx.HTTP_PUT,
+                 [[{
+                        "methods": ["GET"],
+                        "plugins": {
+                            "proxy-rewrite": {
+                                "uri": "/server_upstream_host"
+                            }
+                        },
+                        "upstream": {
+                            "nodes": {
+                                "127.0.0.1:1979": 1,
+                                "127.0.0.1:1980": 1000
+                            },
+                            "type": "roundrobin",
+                            "pass_host": "node"
+                        },
+                        "uri": "/hello"
+                }]]
+                )
+
+            if code >= 300 then
+                ngx.status = code
+            end
+            ngx.say(body)
+        }
+    }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 22: hit route
+--- request
+GET /hello
+--- response_body
+127.0.0.1:1980
+--- no_error_log
+[error]

Review comment:
       Also need to cover the case with retry: 
https://github.com/apache/apisix/blob/530fb4d62c990ec23026f43f70b878e157d441bc/t/node/upstream.t#L458
   
   ```
   "nodes": {
                           "127.0.0.1:1979": 1000,
                           "localhost:1980": 1
                       }
   ```
   We use 1979, a nonexistent port to trigger the retry.




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