apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.35k stars 2.49k forks source link

bug: http_x_forwarded_for doesn't seem right #11283

Open Sarkie opened 4 months ago

Sarkie commented 4 months ago

Current Behavior

When using http_x_forwarded_for in the logs, the order doesn't look to be right and also there's an issue with the comma+space aspect. Unsure if this is an Nginx bug or an apisix bug

Expected Behavior

When using http_x_forwarded_for you will get https://en.wikipedia.org/wiki/X-Forwarded-For

"where the value is a comma+space separated list of IP addresses,"

X-Forwarded-For: client, proxy1, proxy2

Error Logs

No response

Steps to Reproduce

  1. use http_x_forwarded_for in access_log_format
  2. Be behind 1 or proxies
  3. Expected result "client, proxy1, proxy2" in the logs
  4. Actual result "proxy1,(NO SPACE)proxy2,(SPACE)client 5 Actual result 2 "proxy1,(NO SPACE)proxy1,(SPACE)client

Environment

nfrankel commented 4 months ago

Could you please make sure the bug is on Apache APISIX side by checking if you reproduce the bug on nginx, please?