mko
mko

Reputation: 7325

Use single domain to host web application and aws api gatwway?

Is it possible to configure dns settings in such way so web application is using www.domain.com and amazon aws api gateway uses www.domain.com/api?

Upvotes: 0

Views: 45

Answers (2)

Ashan
Ashan

Reputation: 19758

You can configure AWS CloudFront as a proxy to map both API Gateway and Web Server (Or web application hosted in AWS S3) as origins. Then configure www.domain.com to point to CloudFront.

This also improves the application performance, if you cache the static content, serving from the web application, by using the CloudFront CDN network of edge locations.

When mapping API Gateway do the following configuration for it to work.

  • Whitelist the headers and exclude Host header.
  • Set TTL values to zero.
  • Make the origin and behaviors for API Gateway https only.
  • To map www.domain.com/api to API Gateway, use the stage name as 'api' with CloudFront behavior mapping for /api/* .

Upvotes: 1

jrtapsell
jrtapsell

Reputation: 7031

Not using pure DNS, it would only let you point a subdomain to a destination, DNS doesn't see the path.

You can use something like nginx to proxy the path, or use api.domain.com for your API, which probably is better, as you don't need to proxy the requests at all.

Upvotes: 3

Related Questions