Integrating AWS API Gateway with Cloud Front without exposing origin

前端 未结 1 1763
没有蜡笔的小新
没有蜡笔的小新 2021-01-16 00:52

I\'m working on a project with serverless architecture.

I\'ve found that though AWS said API Gateway can protect your resources from DDoS attack.

But if ther

1条回答
  •  星月不相逢
    2021-01-16 01:13

    Check the "Viewer Protocol Policy" on your additional CloudFront distribution (cdn.net) and ensure that it is set to either "Redirect HTTP to HTTPS" or "HTTPS Only". Alterntively, you can edit your origin and set "Origin Protocol Policy" to "HTTPS Only".

    If you have "Viewer Protocol Policy" set to "HTTP and HTTPS" and "Origin Protocol Policy" set to "Match Viewer", then I can see how you would get this result. You enter http://cdn.net/posts on browser, then the cdn.net distribution attempts to connect to http://sampleagigw.amazon.com (no https/tls/ssl). This goes to the CloudFront distribution created by API Gateway which is set to "Redirect HTTP to HTTPS". Since it got an HTTP request, it returns a 302 redirect to http://sampleagigw.amazon.com. This is returned by the cdn.net distribution to the browser. The browser then follows the 302 redirect, leaving the http://sampleagigw.amazon.com URL in the browser's URL bar.

    0 讨论(0)
提交回复
热议问题