How to make AWS api gateway instead of http instead of https

I have a Lambda function proxied by an API gateway. However, API Gateway only provides http s , not http. I've searched everywhere but it looks like API Gateway can't accept HTTP.

So my question is how to translate HTTP client calls to https and send to the api gateway? I ask because my client can only make http calls and they will not change.

+3


source to share


3 answers


I recently had a 4 hour phone call with an AWS representative about a similar issue we had during the production phase. My situation was similar, we couldn't change anything in APIGateway to fix it (the rap tried all sorts of tricks, but nothing seemed to work). So our conclusion was to deploy the EC2 instance as a proxy for APIGateway and redirect all traffic. There was some additional work, such as transferring the domain name, but overall it worked fine. In your case, since you only need to redirect the HTTP traffic, a simple ElasticBeanstalk proxy is sufficient (EB uses HTTP by default and is behind the Nginx proxy).



+4


source


You can place the Cloudfront distribution in front of the API gateway with the following setup:



  • Origin protocol policy: HTTPS only
  • Browsing Protocol Policy: HTTP and HTTPS
  • Forward Headers: No
  • Object Caching: Using Source Cache Headers.
+3


source


CloudFront is a quick fix because it is much easier to set up than creating an Elastic Beanstalk.

I spent a couple of hours trying to get this right, so just share some good reviews and another gentle reminder:

  • This Smartcam project uses Amazon and CloudFront API Gateway and details the setup procedure.
  • the official example given in the Amazon doc demonstrates how to create a GET and POST method using query string parameters (e.g. / search? keyword = mars & ...), a JSON payload, and plus path parameters . Be sure to read!
  • Personal 2 cents:
    • if you are using query string parameters, be sure to edit the behavior cloud paneland then select forward all, cache everything in Forwarding and query string caching .select request forwarding
    • Alternatively, read this document for two more possible configurations.
    • If you have already installed the original path in a variable stage (default /prod

      ), when you call your domain CloudFront, miss /prod

      , simply: xxxx.cloudfront.net/resource1/resource2?param1=...&param2=..

      .screenshot of source path
0


source







All Articles