how to pass the original url from API Gateway to the backend service

0

a REST service runs in EC2 in a private VPC. The request flow: API Gateway -> ELB -> Rest service. A custom domain, like public.aws.example.com, is set up for the API Gateway.

create a resource like /hello, adds a POST Integration request for the resource. In the Integration request methods, set below:

  1. select "VPC Link"
  2. enable "VPC proxy integration"
  3. HTTP method: "POST"
  4. VPC link: "[Use stage variable]"
  5. input: ${stageVariables.vpcLinkId}, the vpcLinkId is set in stage.
  6. Endpoint URL: http://prod-vpclink-rest.us-west-2.amazonaws.com/hello

The backend REST service receives the request from API Gateway, the request's url is http://prod-vpclink-rest.us-west-2.amazonaws.com/hello. How does API Gateway pass the original request url, like public.aws.example.com/hello, to the REST service?

1 回答
0
已接受的回答

the answer is similar with https://repost.aws/knowledge-center/forward-host-header-api-gateway

basically two steps:

  1. In Method Request, add HTTP Request Headers as host.
  2. In Integration Request, "URL request headers parameters", add "Name" like 'x-org-url', "Mapped from" input "method.request.header.host"
已回答 4 个月前
profile pictureAWS
专家
已审核 4 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则