You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apisix.apache.org by Kwanhur Huang <hu...@163.com> on 2022/03/24 14:03:45 UTC

[DISCUSS][Change] Support set redirect server port under http_to_https mode in plugin redirect

hi, the community

Issue #4400 <https://github.com/apache/apisix/issues/4400> point out that, expectedly modify default redirect server port. Original description:

Can the port be set for http_to_https in the redirect plugin?

The default https port of apisix is 9443, but after I set http_to_https to true,
visiting "http://test.com:9080/service/ <http://test.com:9080/service/>"
will redirect to "https://test.com/service/ <https://test.com/service/>",
my expected to jump to "https://test.com:9443/service/ <https://test.com:9443/service/>"


From comment <https://github.com/apache/apisix/pull/6686#issuecomment-1075798013> posts that better to extend `uri` attribute. This will bring a big change under http_to_https mode, as my explanation here <https://github.com/apache/apisix/pull/6686#issuecomment-1075886567>.


Key-point Only one of http_to_https, uri or regex_uri can be specified.

Extends uri under http_to_https mode, it’ll break this limitation.


Hoping hear your voice.


Kwanhur Huang
TL;DR





Kwanhur Huang
TL;DR


Re: [DISCUSS][Change] Support set redirect server port under http_to_https mode in plugin redirect

Posted by Kwanhur Huang <hu...@163.com>.
This style had supported under uri mode.


Kwanhur Huang
TL;DR

> 2022年3月25日 上午9:06,YuanSheng Wang <me...@apache.org> 写道:
> 
> I prefer this style, it's easier to read.
> 
> "plugins": {
>        "redirect": {
>        "uri": "https://$host:9443$request_uri <https://$host:9443$request_uri>",
>        "ret_code": 301
>     }
> }
> 
> 
> 
> On Thu, Mar 24, 2022 at 10:04 PM Kwanhur Huang <huang_hua2012@163.com <ma...@163.com>>
> wrote:
> 
>> hi, the community
>> 
>> Issue #4400 <https://github.com/apache/apisix/issues/4400 <https://github.com/apache/apisix/issues/4400>> point out
>> that, expectedly modify default redirect server port. Original description:
>> 
>> Can the port be set for http_to_https in the redirect plugin?
>> 
>> The default https port of apisix is 9443, but after I set http_to_https to
>> true,
>> visiting "http://test.com:9080/service/ <http://test.com:9080/service/> <http://test.com:9080/service/ <http://test.com:9080/service/>>"
>> will redirect to "https://test.com/service/ <https://test.com/service/> <https://test.com/service/ <https://test.com/service/>>",
>> my expected to jump to "https://test.com:9443/service/ <https://test.com:9443/service/> <
>> https://test.com:9443/service/ <https://test.com:9443/service/>>"
>> 
>> 
>> From comment <
>> https://github.com/apache/apisix/pull/6686#issuecomment-1075798013 <https://github.com/apache/apisix/pull/6686#issuecomment-1075798013>> posts
>> that better to extend `uri` attribute. This will bring a big change under
>> http_to_https mode, as my explanation here <
>> https://github.com/apache/apisix/pull/6686#issuecomment-1075886567 <https://github.com/apache/apisix/pull/6686#issuecomment-1075886567>>.
>> 
>> 
>> Key-point Only one of http_to_https, uri or regex_uri can be specified.
>> 
>> Extends uri under http_to_https mode, it’ll break this limitation.
>> 
>> 
>> Hoping hear your voice.
>> 
>> 
>> Kwanhur Huang
>> TL;DR
>> 
>> 
>> 
>> 
>> 
>> Kwanhur Huang
>> TL;DR
>> 
>> 
> 
> -- 
> 
> *MembPhis*
> My GitHub: https://github.com/membphis <https://github.com/membphis>
> Apache APISIX: https://github.com/apache/apisix <https://github.com/apache/apisix>

Re: [DISCUSS][Change] Support set redirect server port under http_to_https mode in plugin redirect

Posted by Kwanhur Huang <hu...@163.com>.
hi, the community

About this issue, to achieve that redirect the specified server port, some information updating:

Plugin redirect support three mode http_to_https, uri and regex_uri, only one of them can be specified [1].

Under `uri` mode, it has supported to specify server port and reach the target, just like mentioned example.

Under `http_to_https` mode, to reach the target, it needs one way to fetch the redirect server port.
Now has two solutions:
a. Add a property port.
b. Reusing property uri.

solution a: it’s simple to achieve, but its extensibility not enough, if need to specify redirect server name, has to add another property.

solution b: it has to specify properties both http_to_https and uri, 
this breaks the original limitation, only one mode can be specified like the test case 21 [2], 
but reusing the uri property, its extensibility is enough.


Hopefully hear your voice.


[1] https://apisix.apache.org/docs/apisix/plugins/redirect <https://apisix.apache.org/docs/apisix/plugins/redirect>
[2] https://github.com/apache/apisix/blob/8df9a7d26585f30f273f819a21c96cf8c9104349/t/plugin/redirect.t#L487 <https://github.com/apache/apisix/blob/8df9a7d26585f30f273f819a21c96cf8c9104349/t/plugin/redirect.t#L487>


Kwanhur Huang
TL;DR

> 2022年3月25日 上午11:25,Chao Zhang <zc...@gmail.com> 写道:
> 
> Hi,
> 
> Agree with this one.
> 
> Chao Zhang
> https://github <https://github/>.com/tokers
> 
> On March 25, 2022 at 09:16:00, YuanSheng Wang (membphis@apache.org <ma...@apache.org>) wrote:
> 
>> I prefer this style, it's easier to read. 
>> 
>> "plugins": { 
>> "redirect": { 
>> "uri": "https://$host:9443$request_uri <https://$host:9443$request_uri>", 
>> "ret_code": 301 
>> } 
>> } 
>> 
>> 
>> 
>> On Thu, Mar 24, 2022 at 10:04 PM Kwanhur Huang <huang_hua2012@163.com <ma...@163.com>> 
>> wrote: 
>> 
>> > hi, the community 
>> > 
>> > Issue #4400 <https://github.com/apache/apisix/issues/4400 <https://github.com/apache/apisix/issues/4400>> point out 
>> > that, expectedly modify default redirect server port. Original description: 
>> > 
>> > Can the port be set for http_to_https in the redirect plugin? 
>> > 
>> > The default https port of apisix is 9443, but after I set http_to_https to 
>> > true, 
>> > visiting "http://test.com:9080/service/ <http://test.com:9080/service/> <http://test.com:9080/service/ <http://test.com:9080/service/>>" 
>> > will redirect to "https://test.com/service/ <https://test.com/service/> <https://test.com/service/ <https://test.com/service/>>", 
>> > my expected to jump to "https://test.com:9443/service/ <https://test.com:9443/service/> < 
>> > https://test.com:9443/service/ <https://test.com:9443/service/>>" 
>> > 
>> > 
>> > From comment < 
>> > https://github.com/apache/apisix/pull/6686#issuecomment-1075798013 <https://github.com/apache/apisix/pull/6686#issuecomment-1075798013>> posts 
>> > that better to extend `uri` attribute. This will bring a big change under 
>> > http_to_https mode, as my explanation here < 
>> > https://github.com/apache/apisix/pull/6686#issuecomment-1075886567 <https://github.com/apache/apisix/pull/6686#issuecomment-1075886567>>. 
>> > 
>> > 
>> > Key-point Only one of http_to_https, uri or regex_uri can be specified. 
>> > 
>> > Extends uri under http_to_https mode, it’ll break this limitation. 
>> > 
>> > 
>> > Hoping hear your voice. 
>> > 
>> > 
>> > Kwanhur Huang 
>> > TL;DR 
>> > 
>> > 
>> > 
>> > 
>> > 
>> > Kwanhur Huang 
>> > TL;DR 
>> > 
>> > 
>> 
>> --  
>> 
>> *MembPhis* 
>> My GitHub: https://github.com/membphis <https://github.com/membphis> 
>> Apache APISIX: https://github.com/apache/apisix <https://github.com/apache/apisix>

Re: [DISCUSS][Change] Support set redirect server port under http_to_https mode in plugin redirect

Posted by Chao Zhang <zc...@gmail.com>.
Hi,

Agree with this one.

Chao Zhang
https://github.com/tokers

On March 25, 2022 at 09:16:00, YuanSheng Wang (membphis@apache.org) wrote:

I prefer this style, it's easier to read.

"plugins": {
"redirect": {
"uri": "https://$host:9443$request_uri",
"ret_code": 301
}
}



On Thu, Mar 24, 2022 at 10:04 PM Kwanhur Huang <hu...@163.com>
wrote:

> hi, the community
>
> Issue #4400 <https://github.com/apache/apisix/issues/4400> point out
> that, expectedly modify default redirect server port. Original
description:
>
> Can the port be set for http_to_https in the redirect plugin?
>
> The default https port of apisix is 9443, but after I set http_to_https
to
> true,
> visiting "http://test.com:9080/service/ <http://test.com:9080/service/>"
> will redirect to "https://test.com/service/ <https://test.com/service/>",
> my expected to jump to "https://test.com:9443/service/ <
> https://test.com:9443/service/>"
>
>
> From comment <
> https://github.com/apache/apisix/pull/6686#issuecomment-1075798013> posts
> that better to extend `uri` attribute. This will bring a big change under
> http_to_https mode, as my explanation here <
> https://github.com/apache/apisix/pull/6686#issuecomment-1075886567>.
>
>
> Key-point Only one of http_to_https, uri or regex_uri can be specified.
>
> Extends uri under http_to_https mode, it’ll break this limitation.
>
>
> Hoping hear your voice.
>
>
> Kwanhur Huang
> TL;DR
>
>
>
>
>
> Kwanhur Huang
> TL;DR
>
>

-- 

*MembPhis*
My GitHub: https://github.com/membphis
Apache APISIX: https://github.com/apache/apisix

Re: [DISCUSS][Change] Support set redirect server port under http_to_https mode in plugin redirect

Posted by YuanSheng Wang <me...@apache.org>.
I prefer this style, it's easier to read.

"plugins": {
        "redirect": {
        "uri": "https://$host:9443$request_uri",
        "ret_code": 301
     }
}



On Thu, Mar 24, 2022 at 10:04 PM Kwanhur Huang <hu...@163.com>
wrote:

> hi, the community
>
> Issue #4400 <https://github.com/apache/apisix/issues/4400> point out
> that, expectedly modify default redirect server port. Original description:
>
> Can the port be set for http_to_https in the redirect plugin?
>
> The default https port of apisix is 9443, but after I set http_to_https to
> true,
> visiting "http://test.com:9080/service/ <http://test.com:9080/service/>"
> will redirect to "https://test.com/service/ <https://test.com/service/>",
> my expected to jump to "https://test.com:9443/service/ <
> https://test.com:9443/service/>"
>
>
> From comment <
> https://github.com/apache/apisix/pull/6686#issuecomment-1075798013> posts
> that better to extend `uri` attribute. This will bring a big change under
> http_to_https mode, as my explanation here <
> https://github.com/apache/apisix/pull/6686#issuecomment-1075886567>.
>
>
> Key-point Only one of http_to_https, uri or regex_uri can be specified.
>
> Extends uri under http_to_https mode, it’ll break this limitation.
>
>
> Hoping hear your voice.
>
>
> Kwanhur Huang
> TL;DR
>
>
>
>
>
> Kwanhur Huang
> TL;DR
>
>

-- 

*MembPhis*
My GitHub: https://github.com/membphis
Apache APISIX: https://github.com/apache/apisix