Skip to content

request help: The X-Forwarded-For header of the request to the upstream cannot be changed #5091

Answered by shuaijinchao
jagerzhang asked this question in Q&A
Discussion options

You must be logged in to vote

Can be handled in this way temporarily

curl -i http://127.0.0.1:9080/apisix/admin/routes/10  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "uri": "/test/index.html",
    "plugins": {
        "serverless-pre-function": {
            "phase": "rewrite",
            "functions": [
                "return function(conf, ctx) ngx.var.var_x_forwarded_for = tostring(\"1.1.1.1\") end"
            ]
        }
    },
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "127.0.0.1:1980": 1
        }
    }
}'

Replies: 4 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by tzssangglass
Comment options

You must be logged in to vote
4 replies
@juzn01
Comment options

@bk13699
Comment options

@bk13699
Comment options

@bk13699
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
enhancement New feature or request good first issue Good for newcomers
5 participants
Converted from issue

This discussion was converted from issue #5080 on September 18, 2021 01:01.