Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using remap plugins for regex matches in the regex_remap plugin #9389

Open
bhaveshpun opened this issue Feb 7, 2023 · 2 comments
Open

Using remap plugins for regex matches in the regex_remap plugin #9389

bhaveshpun opened this issue Feb 7, 2023 · 2 comments

Comments

@bhaveshpun
Copy link

We're currently using ATS v8.1.1.
To support regular expressions in request paths, we've been trying to use the regex_remap plugin in the mapping rules

Our remap rules look like this:

map https://example.com/.*.mp4 https://example.com/.*.mp4 @action=allow @method=get \
@plugin=regex_remap.so @pparam=maps.reg \
@plugin=url_sig.so @pparam=url_sig.config @pparam=pristineurl \
@plugin=compress.so @pparam=example.config \

map https://example.com/ https://example.com/ @action=allow @method=post @method=get \
@plugin=regex_remap.so @pparam=maps.reg \

Rules in the maps.reg file are defined in the following way:

^/.*mp4 $s://$f/$0

We would want to use the signed url plugin, the compression plugin and the allowed methods defined in the .*mp4 mapping rule on requests that match the .*mp4 regex.

For example, requests of the type https://example.com/abc.mp4 should be signed and only get method should be allowed for them.

With the current configurations, https://example.com/abc.mp4 matches the second mapping rule. Post method is allowed for such a request, signed urls are not required and compression isn't supported as well.

Is there a way in which we can enable the use of different remap plugins for different regex rules in the maps.reg file ?
Or is there a simpler workaround for requests to match mapping rules containing regex quantifiers ?

@zwoop
Copy link
Contributor

zwoop commented Feb 22, 2023

You can't match on regular expressions like that on the path, so in your case, everything matches the second "map" rule. There's also no way to control different plugins to be run based on the path like that either, the regex_remap plugin does not support that.

I don't know that there's any solution here which would allow you to run the remap plugins conditionally like this.

Copy link

This issue has been automatically marked as stale because it has not had recent activity. Marking it stale to flag it for further consideration by the community.

@github-actions github-actions bot added the Stale label Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants