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 Answer
0
Accepted Answer

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"
answered 4 months ago
profile pictureAWS
EXPERT
reviewed 4 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions