You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/01/26 13:30:49 UTC
[GitHub] [apisix] halfcrazy opened a new pull request #3428: feat: proxy-rewrite host support host with port
halfcrazy opened a new pull request #3428:
URL: https://github.com/apache/apisix/pull/3428
### What this PR does / why we need it:
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
proxy-rewrite plugin support override host with port, rel pr #2079
### Pre-submission checklist:
* [ ] Did you explain what problem does this PR solve? Or what new features have been added?
* [ ] Have you added corresponding test cases?
* [ ] Have you modified the corresponding document?
* [ ] Is this PR backward compatible? **If it is not backward compatible, please discuss on the [mailing list](https://github.com/apache/apisix/tree/master#community) first**
----------------------------------------------------------------
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:
users@infra.apache.org
[GitHub] [apisix] Firstsawyou commented on a change in pull request #3428: feat: proxy-rewrite host support host with port
Posted by GitBox <gi...@apache.org>.
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:
users@infra.apache.org
[GitHub] [apisix] spacewander merged pull request #3428: feat: proxy-rewrite host support host with port
Posted by GitBox <gi...@apache.org>.
spacewander merged pull request #3428:
URL: https://github.com/apache/apisix/pull/3428
----------------------------------------------------------------
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:
users@infra.apache.org