Skip to content

feat: As a user, I want to use Nginx variables in proxy-rewrite.regex_uri #13140

@mikyll

Description

@mikyll

Description

Currently, proxy-rewrite supports NGINX variable resolution in uri config parameter, but not in regex_uri. See APISIX Docs | Plugins - proxy-rewrite for reference.

Examples:

  • 🟢 Nginx variable resolution in uri:

    proxy-rewrite:
      uri: /api/$arg_name
  • 🟢 Pattern variable resolution in regex_uri:

    proxy-rewrite:
      regex_uri:
        - ^/api/(.*)/users/(.*)$
        - /v2/$1/external-users/$2
  • 🔴 Nginx variable resolution in regex_uri:

    proxy-rewrite:
      regex_uri:
        - ^/api/(.*)/users/(.*)$
        - /v2/$1/external-users/$arg_name

    This is not allowed and will throw an error.

Question

Since regex_uri already supports variables resolution for regex patterns (e.g. patterns matched by (.*)/(.*) can be referenced with $1 and $2), I was wondering: why does uri allow Nginx variables resolution, but regex_uri does not? Is this a design choice? Are there any contraindications in implementing this feature?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions