Firstsawyou commented on a change in pull request #3428:
URL: https://github.com/apache/apisix/pull/3428#discussion_r564581656
##########
File path: t/plugin/proxy-rewrite.t
##########
@@ -1297,3 +1297,79 @@ GET /test?new_uri=hello
hello world
--- no_error_log
[error]
+
+
+
+=== TEST 44: host with port
+--- config
+ location /t {
+ content_by_lua_block {
+ local plugin = require("apisix.plugins.proxy-rewrite")
+ local ok, err = plugin.check_schema({
+ host = 'apisix.iresty.com:6443',
+ })
+ if not ok then
+ ngx.say(err)
+ end
+
+ ngx.say("done")
+ }
+ }
+--- request
+GET /t
+--- response_body
+done
+--- no_error_log
+[error]
+
+
+
+=== TEST 45: set route(rewrite host with port)
+--- 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": "/uri",
+ "host": "test.com:6443",
+ "scheme": "https",
+ }
+ },
+ "upstream": {
+ "nodes": {
+ "127.0.0.1:1983": 1
+ },
+ "type": "roundrobin"
+ },
+ "uri": "/hello"
+ }]]
+ )
+
+ if code >= 300 then
+ ngx.status = code
+ end
+ ngx.say(body)
+ }
+ }
+--- request
+GET /t
+--- response_body
+passed
+--- no_error_log
+[error]
+
+
+
+=== TEST 46: rewrite host with port
+--- request
+GET /hello HTTP/1.1
+--- response_body
+uri: /plugin_proxy_rewrite
+host: test.com:6443
+--- no_error_log
+[error]
Review comment:
Try this:
```
=== TEST 46: rewrite host with port
--- request
GET /hello
--- response_body
uri: /uri
host: test.com:6443
x-real-ip: 127.0.0.1
--- no_error_log
[error]
```
##########
File path: t/plugin/proxy-rewrite.t
##########
@@ -1297,3 +1297,79 @@ GET /test?new_uri=hello
hello world
--- no_error_log
[error]
+
+
+
+=== TEST 44: host with port
+--- config
+ location /t {
+ content_by_lua_block {
+ local plugin = require("apisix.plugins.proxy-rewrite")
+ local ok, err = plugin.check_schema({
+ host = 'apisix.iresty.com:6443',
+ })
+ if not ok then
+ ngx.say(err)
+ end
+
+ ngx.say("done")
+ }
+ }
+--- request
+GET /t
+--- response_body
+done
+--- no_error_log
+[error]
+
+
+
+=== TEST 45: set route(rewrite host with port)
+--- 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": "/uri",
+ "host": "test.com:6443",
+ "scheme": "https",
Review comment:
How about this:
```
"uri": "/uri",
"host": "test.com:6443"
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]