当前位置: 首页 > article >正文

AWS中使用CloudFront分发位于S3中的静态网站

这是其中一种方法,可有变化

假设主页为index.html

还要准备一个证书,要覆盖子域名(AWS Certificate Manager->Certificates)

1、S3->Create bucket->Bucket name(myweb)->Create bucket

2、S3->Buckets->myweb->Upload->Add files Add folder

3、CloudFront->Distributions->Create->Origin domain(myweb.s3.amazonows.com)->Name(myweb)->Origin access(Origin access control settings (recommended))->Origin access control->Create new OAC->复制到S3->Alternate domain name (CNAME) - optional->Add item->(www.youweb.com)->Custom SSL certificate - optional(提前准备好证书)->Create distribution

4、Amazon S3->Buckets->myweb->Permissions->Bucket policy->Edit->粘贴到S3

5、Route 53->Hosted zones->配置域名记录

6、问题:www.youweb.com不能访问,只能访问www.youweb.com/index.html

6.1、办法,CloudFront Functions:

6.2、CloudFront->Functions->Create function->Name(index)->Create function

function handler(event) {
    var request = event.request;

    // 如果请求路径是根路径(/),重写为 /index.html
    if (request.uri === '/') {
        request.uri = '/index.html';
    }

    return request;
}

6.3、CloudFront->Functions->index->Publish->Publish function

6.4、CloudFront->Distributions->myweb->Behaviors->Edit->Function associations - optional->Viewer request->Function type->CloudFront Functions->Function ARN / Name(index)


http://www.kler.cn/a/578752.html

相关文章:

  • SV学习笔记——数组、队列
  • spring boot+vue项目(免费)
  • es-初体验easy-es时报错:找不到mapper
  • Vue 过滤器 filter(s) 的使用
  • win32汇编环境,对话框中使用树形视图示例四
  • Objective-C 中 @synthesize VS @dynamic
  • webtinyserver讲解
  • pytorch retain_grad vs requires_grad
  • 电路研究9.3.1——合宙Air780EP中的AT开发指南:TCP 使用 SSL 示例
  • 关于VScode终端无法识别外部命令
  • mysql安装(演示为mac安装流程)
  • 使用 Python 批量提取 PDF 书签:一款实用工具的实现
  • Hadoop集群搭建(一)安装jdk
  • Nacos高频面试题10个
  • 深度学习与数据挖掘题库:401-500题精讲
  • 技术领域,有许多优秀的博客和网站
  • 基于PaddleNLP使用DeepSeek-R1搭建智能体
  • 【Linux篇】:Linux常用工具全解析--探索高效的工具宝藏
  • 生活反思公园散步与小雨遇记
  • Opencv之掩码实现答题卡识别及正确率判断