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

feat: Support adding header in proxy-rewrite plugin #8239

Closed
AlinsRan opened this issue Nov 3, 2022 · 7 comments · Fixed by #8336
Closed

feat: Support adding header in proxy-rewrite plugin #8239

AlinsRan opened this issue Nov 3, 2022 · 7 comments · Fixed by #8336
Assignees
Labels
good first issue Good for newcomers

Comments

@AlinsRan
Copy link
Contributor

AlinsRan commented Nov 3, 2022

Description

Currently, proxy-rewrite plugin only supports set / delete headers. The limitation makes some operations impossible. This feature is required to implement Gateway API HTTPHeaderFilter.

Expect

{
    "proxy-rewrite": {
        "headers": {
            "add": {
                "X-Server-id": 3,
                "X-Server-status": "on",
                "X-Server-balancer_addr": "$balancer_ip:$balancer_port"
            }
        }
    }
}

Actual

{
    "proxy-rewrite": {
        "headers": {
            "X-Api-Version": "v1",
            "X-Api-Engine": "apisix",
            "X-Api-useless": ""
        }
    }
}
@AlinsRan AlinsRan added the good first issue Good for newcomers label Nov 3, 2022
@mscb402
Copy link
Contributor

mscb402 commented Nov 3, 2022

please assign to me

@AlinsRan AlinsRan assigned AlinsRan and mscb402 and unassigned AlinsRan Nov 3, 2022
@AlinsRan
Copy link
Contributor Author

AlinsRan commented Nov 3, 2022

@spacewander cc

@tzssangglass
Copy link
Member

@AlinsRan
Copy link
Contributor Author

AlinsRan commented Nov 7, 2022

proxy-rewrite plugin support to add headers, read: https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/proxy-rewrite.md#attributes

If the header exists, it will be overwritten.

Expect:

  1. current: Cache-Control: max-age
  2. add plugin
{
    "proxy-rewrite": {
        "headers": {
            "add": {
                "Cache-Control": "must-revalidate",
            }
        }
    }
}
  1. result: Cache-Control: max-age, must-revalidate

Actual:

  1. current: Cache-Control: max-age
  2. add plugin
{
    "proxy-rewrite": {
        "headers": {
             "Cache-Control": "must-revalidate"
        }
    }
}
  1. result: Cache-Control: must-revalidate

@tokers
Copy link
Contributor

tokers commented Nov 7, 2022

I think the design of this part should be consistent with response-rewrite.

@tokers
Copy link
Contributor

tokers commented Nov 7, 2022

cc @mscb402

@GitTest16
Copy link

Does this add plugin add value multiple time ? I am experiencing that header value get added two time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants