You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/09/17 05:52:37 UTC

[GitHub] [apisix] jagerzhang edited a comment on issue #5080: request help: The X-Forwarded-For header of the request to the upstream cannot be changed

jagerzhang edited a comment on issue #5080:
URL: https://github.com/apache/apisix/issues/5080#issuecomment-921517340


   > Can be handled in this way temporarily
   > 
   > ```shell
   > 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
   >         }
   >     }
   > }'
   > ```
   > 
   > ![image](https://user-images.githubusercontent.com/8529452/133728294-61d6f5ac-6ecb-470b-be9c-7646715ac590.png)
   
   @shuaijinchao 
   it works for me, tks! 
   
   There is only one difference in variable name between Kong gateway and APISIX gateway:
   `ngx.var.upstream_x_forwarded_for  ==>  ngx.var.var_x_forwarded_for`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org