dylanoy commented on issue #9530:
URL: https://github.com/apache/apisix/issues/9530#issuecomment-2065674070

   I've tried all the suggestions mentioned above, including:
   ```
   ngx.req.proxy_set_header('X-Forwarded-For', '127.0.0.1')`
   ```
   ```
   ngx.var.var_x_forwarded_for='127.0.0.1'
   ```
   ```
   require('apisix.core').request.set_header(ctx, 'X-Forwarded-For', '')
   ```
   and using
   ```json
   "proxy-rewrite": {
        "headers": {
                "remove": [
                        "X-Forwarded-For",
                        "X-Real-IP"
                ]
        }
   }
   ```
   
   However, none of these methods were able to remove the X-Forwarded-For 
header sent to the upstream server or modify its value. I also couldn't change 
the value of X-Real-IP.
   
   Finally, I found a solution by referring to the realip module. Using the 
following configuration, I was able to successfully modify the X-Real-IP and 
X-Forwarded-For headers sent to the upstream server:
   ```json
   "serverless-post-function": {
        "functions": [
                "return function() local _, client = pcall(require, 
'resty.apisix.client')\nclient.set_real_ip('127.0.0.1', 80); end"
        ],
        "phase": "rewrite"
   }
   ```
   
   I'm sharing this here as a reference for anyone who encounters the same 
issue or needs to modify these two header values.
   
   Hope everyone has a wonderful day


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to