Dan Jenson
Dan Jenson

Reputation: 1041

AWS API Gateway HTTP Proxy for HTTPS connections

I cannot for the life of me get the AWS API Gateway HTTP Proxy to work, i.e. redirect http://<my-domain>.com to https://<my-domain>.com. Here is how I set it up: resource setup any method

Using the Test functionality on the ANY method inside the resource works. But if I simply do curl http://<my-domain>.com or run http://<my-domain>.com in Chrome, it fails to connect; https://<my-website>.com works just fine. I'm driving myself crazy trying to figure out what I'm missing here; it seems like it should just redirect http://<my-domain>.com to https://<my-domain>.com, but it doesn't (even on different devices).

Upvotes: 2

Views: 3598

Answers (2)

jellycsc
jellycsc

Reputation: 12359

API Gateway doesn't support unencrypted HTTP traffic. Here are the possible options you can do to secure your website:

  • If you have access to the server that hosts the website, install an SSL certificate to the webserver.

  • If the website is hosted on EC2, you can set up a load balancer and let it do the SSL termination.

Upvotes: 0

Dan Jenson
Dan Jenson

Reputation: 1041

So, it turns out that API Gateway's HTTP Proxy allows HTTPS traffic to go to an HTTP endpoint, but not the reverse. In fact, API Gateway won't even establish a connection on port 80; from the FAQ:

Q: Can I create HTTPS endpoints?

Yes, all of the APIs created with Amazon API Gateway expose HTTPS endpoints only. Amazon API Gateway does not support unencrypted (HTTP) endpoints.

Upvotes: 3

Related Questions