跳至內容

HTTP API GW + VPC Link + Private ALB = Lost X-Forwarded-For header. Why?

0

I’m working with an HTTP API Gateway integrated with a private load balancer via a VPC Link. When my backend receives a request, the X-Forwarded-For header only contains the private IP from the load balancer. I’ve configured the load balancer to forward this header:

• With preserve, I don’t get the header at all.

• With append, I receive the header, but it only contains a private IP.

I believe this is the only header being altered. Does this make sense? Is this an expected behavior?

How I tested this:

• Added a Lambda as an integration of my API, sent a request, and the header was there with my public IP.

• Used the same configuration in the ALB and forwarded traffic to a Lambda, but got no header at all with the preserve config.

已提問 1 年前檢視次數 491 次
1 個回答
0

Have you tried adding a parameter mapping to the integration in API Gateway? I haven't tried it but you may have to append a dummy value because there's no "preserve" setting, only "overwrite", "remove" and "append".

AWS
專家
已回答 1 年前
  • Yes, I can add the IP to a custom header, and that header will be available after passes through the VPC Link and the ALB. The problem is that I'm dealing with a Legacy application that no one in the team knows how it works. So I can not update the code to make it work with a different header.

    Just to be clear, X-Forwarded-For is available in the API GW, the header vanish after passing though the VPC Link integration.

  • In that case I would create a support case to see if this is behaviour that is expected from the service or not.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。