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 Antwort
0
Akzeptierte Antwort

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"
beantwortet vor 4 Monaten
profile pictureAWS
EXPERTE
überprüft vor 4 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen