S3托管+ Api网关 [英] S3 Hosting + Api Gateway

查看:70
本文介绍了S3托管+ Api网关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在S3中托管一个静态站点,以便能够使用Lambda/Api网关处理一些动态内容.似乎无法做到这一点.我希望网址看起来像这样:

I'm trying to host a static site in S3 with ability to handle some dynamic content using Lambda/Api Gateway. Can't seem to be able to do that. I want URLs to look like this:

example.com/index.html
example.com/images/*
example.com/css/*
example.com/api/* -> API Gateway 

此外,重定向时,我想将example.com保留为根域.我在S3中尝试过RoutingRules,但从客户端重定向.我需要对用户透明,例如代理请求.

Also, when redirecting I'd like to keep the example.com as a root domain. I tried RoutingRules in S3, but redirects from the client. I need this to be transparent from the user, like proxying requests.

推荐答案

您可以通过将CloudFront发行版放置在API网关API和S3存储桶的前面以获取静态内容来进行配置.这也将使您能够利用CloudFront的边缘缓存.

You can configure this by putting a CloudFront distribution in front of both the API Gateway API and the S3 bucket for static content. This would also allow you to take advantage of CloudFront's edge caching.

这篇关于S3托管+ Api网关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆