You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何限制API Gateway仅允许CloudFront访问?

配置CloudFront限制API Gateway访问的方案

我目前拥有一个CloudFront分发,通过**Origin Access Control(OAC)**限制对存储静态内容的S3存储桶的访问。

我希望对API Gateway执行同样的配置,目标架构如下:

┌───────────────────────────────────────────────────────────────────────────┐
                     │AWS Account                                                                │
                     │                                               ┌──────────────────────┐    │
                     │                                        *      │     S3 Bucket        │    │
                     │                                       ┌──────►│  (static content)    │    │
                     │                                       │       └──────────────────────┘    │
┌─────────────┐      │  ┌────────────────────────────┐       │                                   │
│             │      │  │                            │       │                                   │
│    Client   ├──────┼─►│  CloudFront Distribution   ├───────┤                                   │
│             │      │  │                            │       │       ┌──────────────────────┐    │
└─────────────┘      │  └────────────────────────────┘       │       │     API Gateway      │    │
                     │                                       └──────►│  (dynamic content)   │    │
                     │                                        /api/* └──────────────────────┘    │
                     │                                                                           │
                     │                                                                           │
                     └───────────────────────────────────────────────────────────────────────────┘

非CloudFront分发的流量应无法访问API Gateway——理想情况是不给它配置公网URL,也可以通过策略进行限制。

我曾看到过一种通过验证分发的秘密标头值实现的解决方案,但与OAC这类方法相比并不理想。


内容的提问来源于stack exchange,提问作者Tom01098

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 14:02:13