首页 > 其他分享 >[1048] Hosting a static website using Amazon S3

[1048] Hosting a static website using Amazon S3

时间:2024-08-27 13:36:51浏览次数:11  
标签:website S3 1048 bucket html static your

ref: Hosting a static website using Amazon S3


To host a static website on an Amazon S3 bucket, follow these steps:

Step-by-Step Guide

  1. Create an S3 Bucket:

    • Open the Amazon S3 console.
    • Click on “Create bucket”.
    • Enter a unique bucket name and choose a region.
    • Click “Create bucket”.
  2. Upload Your Website Files:

    • Select your newly created bucket.
    • Click on “Upload” and add your website files (e.g., index.html, error.html).
  3. Enable Static Website Hosting:

    • Go to the “Properties” tab of your bucket.
    • Scroll down to “Static website hosting” and click “Edit”.
    • Select “Use this bucket to host a website”.
    • Specify the index document (e.g., index.html) and error document (e.g., error.html).
    • Click “Save changes”.
  4. Set Bucket Policy for Public Access:

    • Go to the “Permissions” tab.
    • Scroll down to “Bucket policy” and click “Edit”.
    • Add a policy to allow public read access:
      {
        "Version": "2012-10-17",
        "Statement": [
          {
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::your-bucket-name/*"
          }
        ]
      }
    • Replace your-bucket-name with the name of your bucket.
    • Click “Save changes”.
  5. Disable Block Public Access:

    • In the “Permissions” tab, click “Edit” under “Block public access (bucket settings)”.
    • Uncheck “Block all public access” and confirm the changes.
  6. Access Your Website:

    • Your website will be available at the endpoint URL provided in the “Static website hosting” section. It will look something like http://your-bucket-name.s3-website-region.amazonaws.com.

Example

If your bucket is named example-bucket and is in the us-east-1 region, your website URL will be:

http://example-bucket.s3-website-us-east-1.amazonaws.com

For more detailed instructions, you can refer to the AWS documentation12.

Would you like help with anything else?


Here’s a simple example of an index.html file for your S3 bucket static website:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Welcome to My Website</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            padding: 50px;
        }
        h1 {
            color: #333;
        }
        p {
            font-size: 18px;
        }
        a {
            color: #007BFF;
            text-decoration: none;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <h1>Welcome to My Website</h1>
    <p>This is a simple static website hosted on Amazon S3.</p>
    <p><a href="https://www.example.com">Learn more</a></p>
</body>
</html>

This index.html file provides a basic structure with a welcoming message and a link.


Here’s a simple example of an error.html file that you can use for your S3 bucket static website hosting:
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Error</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            text-align: center;
            padding: 50px;
        }
        h1 {
            color: #ff0000;
        }
        p {
            font-size: 18px;
        }
    </style>
</head>
<body>
    <h1>Oops! Something went wrong.</h1>
    <p>The page you are looking for might have been removed, had its name changed, or is temporarily unavailable.</p>
    <p><a href="/">Go to Homepage</a></p>
</body>
</html>
This error.html file provides a user-friendly error message and a link to return to the homepage.         

标签:website,S3,1048,bucket,html,static,your
From: https://www.cnblogs.com/alex-bn-lee/p/18382531

相关文章

  • [1046] Different permissions in the AWS S3 policy
    Thes3:GetObjectpermissioninanAWSS3policyallowsausertoretrieveobjects(files)fromanS3bucket.Thispermissioniscrucialforreadaccess,enablinguserstodownloadorviewthecontentsoftheobjectsstoredinthebucket123.Here’sanexam......
  • 如何使用 AWS CLI 为私有 AWS S3 存储桶中的对象创建预签名 URL
    本文档的目的是介绍使用AWSCLI为s3对象创建预签名URL的步骤。欢迎来到雲闪世界。快速事实“如果您使用预签名URL,则无需将存储桶公开,事实上,最好不要这样做。”—AWSSupport背景AmazonWebServices简单存储服务(AWSS3)是AWS的服务之一,您可以以低廉的价格......
  • CSS3新特性
    一、圆角1、border-radius属性(圆角)通过​border-radius​属性可以给任何元素设置​“圆角”​。如果你在​border-radius属性中只指定​一个值​,那么将生成​4个圆角​。但是,如果你要在四个角上​一一指定​,可以使用以下规则:​四个值​: 第一个值为​左上角​,第二个值......
  • ECOS3010 mathematical equations
    ECOS3010:Assignment1(Total:20marks)Due11:59pm,FridayAug30,20241.Homeworkmustbeturnedinonthedayitisdue.Worknotsubmittedonorbeforetheduedateissubjecttoapenaltyof5%percalendardaylate.Ifworkissubmittedmorethan......
  • CSS3页面布局-三栏-固定宽度布局
    布局的基本概念多栏布局三种基本实现方案:固定宽度,流动,弹性。固定宽度布局:大小不会随用户调整浏览器窗口大小。一版960-1100,960常见,可以被3,4,5,6,8,10,12,16整除。流动布局:大小会随用户调整浏览器窗口大小而变化。可以更好适应大屏幕,也叫响应式。弹性布局:所有元素大小也......
  • 【S32K144 不能正常debug问题】
    目录问题描述rootcause:解决方法:测试验证:问题描述工具:EBTresos+S32DS在开发S32K144的过程中,遇到了debug运行跑飞的情况,具体现象为:当程序包含Port_Init函数时,运行到Port_Init内的某一行,程序突然跑飞,不能停在下一行的断点上,Port_Init函数后的其他任一行也不能停在......
  • RTX 40全系10款显卡《黑神化:悟空》测试:打开DLSS3帧生成 性能直翻4倍
    一、前言:《黑神话:悟空》临近发布RTX40系显卡表现如何?2020年8月20日,游戏科学发布了《黑神话:悟空》的首个实机演示预告,惊艳了整个游戏行业!以往,很多人认为国产开发商做不出优质的3A单机游戏,但是《黑神话:悟空》的出现,直接打破了这一固有观念!《黑神话:悟空》在8月20日10点正式解禁,......
  • centos7安装FreeRadius3及WEB管理界面DaloRadius
    一、基础环境安装1.安装基础环境yum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-......
  • S32的进阶之路->1,S32DS环境安装与Debuge测试
    1,S32DS安装包下载    浏览器搜索“恩智浦”进入NXP官网,或者直接点击下面的NXP官网链接NXP官网https://www.nxp.com.cn/    进入设计中心,点击软件下面的汽车软件,随后进入到汽车电子软件和工具界面,再点击S32DSIDE进行下载,这里我们需要登录NXP的账号,没有的......
  • S32G A核之——SD卡镜像生成及烧写
    S32GA核之——SD卡镜像生成及烧写1、将SD卡的内容合成镜像文件(.img)1.虚拟机识别到SD卡。2.查看SD卡名字。cat/proc/partitions 3.生成镜像文件sudoddif=/dev/sdbof=dump.imgbs=1Mcount=3004.成功5.注释if:跟要合成或者烧写的文件of:烧写或者合成到哪bs......