Configure DNS with Cloudflare on Amazon API Gateway

I have a mydomain.com website with DNS configured through Cloudflare. I am in the process of creating an API accessible through api.mydomain.com

The servers I use are hosted on Digital Ocean, but I would like to use some of the features of the Amazon API Gateway interface (later I will transfer all the servers to Amazon). The API server is the same as the website (again, this will be split later, but for now, the effective A record is the same Digital Ocean node). The API gateway interface is configured and I can only access it through the provided endpoint someamazonendpointurl.com/stage

On Amazon, I created a Cloudflare distribution with the source api.mydomain.com. It has some basic HTTP-HTTPS behaviors, as well as query string parameters. Then I set up a CNAME record in Cloudflare to specify the endpoint URL. When I try to access api.mydomain.com, although I get a Chrome error:

ERR_TOO_MANY_REDIRECTS 

Does anyone know that I might have misconfigured. I understand that this is a bit of a weird setup, but this is the amount of time that we move our servers to Amazon.

UPDATE

I noticed that I had a cloud CNAME record on api.mydomain.com. Now I deleted it, but we get:

 ERROR The request could not be satisfied. Bad request. Generated by cloudfront (CloudFront) Request ID: <id> 
+5
source share
1 answer

Most likely, your SSL mode on Cloudflare is set to Flexible, which does not use https to connect to the source server. The API gateway is trying to redirect unsafe requests, so you have a redirect cycle.

Set your SSL mode to Full and you should be good to go! You can do this on the "Crypto" tab of the Cloudflare toolbar.

0
source

Source: https://habr.com/ru/post/1247411/


All Articles