1
votes

An IoT device is sending data:

  • by POST method
  • by HTTP (not HTTPS)
  • and doesn't follow redirects

I created an end-point on AWS API GateWay and I created an AWS CloudFront and configured like this:

  • Origin Domain Name: myAPIgw.execute-api.us-west-1.amazonaws.com
  • Origin Protocol Policy: HTTPS Only
  • Viewer Protocol Policy: Redirected HTTP to HTTPS
  • Allowed HTTP Methods: GET, HEAD, OPTIONS, PUT, POST, PATCH, DELETE
  • Cache Policy: Managed-CachingDisabled

When I send request by Postman (auto follow redirect turned off) these are responses:

POST https://myAPIgw.execute-api.us-west-1.amazonaws.com --> 200 Success

POST https://Mycloudfront.cloudfront.net --> 200 Success

POST http://Mycloudfront.cloudfront.net --> 307 Temporary Redirect

Any idea to get 200 by HTTP ?

1
Set viewer protocol to HTTP? I'm not sure what do you aim to achieve? You want to use only HTTP or HTTPS?Marcin
@Marcin I want to send data by http but API Gateway only works by https so I sent data to cloud front then cloudFront ridirects http to https then send it to Api Gatewaysamurai_code

1 Answers

1
votes

If you want to use HTTP, then you should set:

Viewer Protocol Policy: HTTP and HTTPS

and

Origin Protocol Policy: HTTPS Only

This way you can query the CloudFront endpoint either using HTTP or HTTPS, and no redirection is required from HTTP to HTTPS.