Skip to content

Odd regex_remap target match string when "host" option is used - contains partial scheme string #12691

@djcarlin

Description

@djcarlin

Using ATS 10.1

I am trying to write a blanket http to https redirect remap rule. I did the following using both the host and pristine options of regex_remap plugin:

# RFC2606 says this tld should never resolve - destination of remap rule is unused in this configration
regex_map http://(.*)   https://unused.invalid @plugin=regex_remap.so @pparam=/opt/regex_remap/plaintext-redirect.config   @pparam=host    @pparam=pristine

And the contents of /opt/regex_remap/plaintext-redirect.config regex_remap plugin config is the following:

^(.*)$ https://$1 @status=307

Whats interesting is that the target match string contains the // from the scheme of the pristine URL which I thought was odd:

[Nov 21 20:45:28.692] [ET_NET 10] DIAG: <regex_remap.cc:948 (TSRemapDoRemap)> (regex_remap) Target match string is `//thisisatest.yahoo.com/?foo=bar&bar=baz'
[Nov 21 20:45:28.692] [ET_NET 10] DIAG: <regex_remap.cc:1014 (TSRemapDoRemap)> (regex_remap) New URL is estimated to be 51 bytes long, or less
[Nov 21 20:45:28.692] [ET_NET 10] DIAG: <regex_remap.cc:1015 (TSRemapDoRemap)> (regex_remap) New URL is https:////thisisatest.yahoo.com/?foo=bar&bar=baz (length 48)
[Nov 21 20:45:28.692] [ET_NET 10] DIAG: <regex_remap.cc:1016 (TSRemapDoRemap)> (regex_remap)     matched rule 1 [^(.*)$]
[Nov 21 20:45:28.692] [ET_NET 10] DIAG: <regex_remap.cc:1028 (TSRemapDoRemap)> (regex_remap) Redirecting URL, status=307

So the working config needs to remove the // from the destination scheme to work:

^(.*)$ https:$1 @status=307

Only with this 2nd config do I get the proper redirect.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions