Apache httpd (mod_proxy) 似乎是 drop/ignore X-Forwarded-For 链中的第 3 个 IP 地址?

Apache httpd (mod_proxy) seems to drop/ignore 3rd IP address in X-Forwarded-For chain?

考虑 scenario/flow:

remote user (client) > proxy1 > proxy2 > AWS ALB > httpd/reverse_proxy > my_application

当用户的请求传出他们的网络时,X-Forwarded-For (XFF) header 会附加每个后续代理的 IP 地址。 例如,当它到达 ALB 时,XFF header 包含“192.168.1.100, 100.99.98.97”。 然后,ALB 会将 ClientIP 附加到此 header,在本例中为 proxy2 的 IP。 最后,当请求到达位于我的应用程序前面的反向代理时,XFF header 现在是:“192.168.1.100, 100.99.98.97, 95.94.93.92”。

我遇到的问题: 在 reverse_proxy 处,httpd 似乎忽略或删除 X-Forwarded-For header 链中的 last/most 正确 IP,特别是当 超过 2 地址。

我不确定我在配置或测试中遗漏了什么,虽然不是标准,但 XFF header 中的多个地址很常见。我只在 Apache httpd 2.4 中遇到这个问题。在 2.2 版中,这不是问题,我可以重复相同的 setup/flow,我会看到链中的所有 3 个地址。 提前致谢。

示例虚拟主机:

<VirtualHost *:80>
  ProxyPreserveHost On
  ServerName myapp.mydomain.com
  Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
  RemoteIPHeader X-Forwarded-For


  ProxyPass / http://10.1.2.3:8080/  timeout=3600
  ProxyPassReverse "/" http://10.1.2.3:8080/

  SetEnv proxy-sendchunked

  ErrorLog /var/log/httpd/error_myapp
  LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined2
  CustomLog /var/log/httpd/access_myapp combined2
  </VirtualHost>

Vhost 缺少 RemoteIPTrustedProxy 指令。

"When multiple, comma delimited useragent IP addresses are listed in the header value, they are processed in Right-to-Left order. Processing halts when a given useragent IP address is not trusted to present the preceding IP address. The header field is updated to this remaining list of unconfirmed IP addresses, or if all IP addresses were trusted, this header is removed from the request altogether."

https://httpd.apache.org/docs/2.4/mod/mod_remoteip.html#remoteiptrustedproxy

和往常一样,答案就在眼前。