Trying to set up API gateway API (to a Lambda service) with an edge optimized custom domain.
Set up custom domain:
A call to the original AWS API URL (https://****.execute-api.****.amazonaws.com/prod
) works perfectly.
But a call to either the ****.cloudfront.net
URL or the custom domain (api.****.com
) returns a Bad Request
:
$ curl https://****.cloudfront.net/**** -H "Host:api.****.com"
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Bad request.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: ***==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>
(Spoofing the Host:
header on that request)
In my domain's DNS settings I've set up a CNAME record to point to the cloudfront URL, and it seems to be working OK.
(On the custom domain I also have an SSL problem I can't get through, but I'd like to get this resolved first...)