amazon s3_在Amazon S3上托管静态网站

news/2024/5/20 8:40:30/文章来源:https://blog.csdn.net/cunchi4221/article/details/107476166

amazon s3

Static website hosting on Amazon S3 is one of the very popular use cases of Amazon S3. It allows you to host an entire static website and on very low cost. Amazon S3 is a highly available and scalable hosting solution.

Amazon S3上的静态网站托管是Amazon S3最受欢迎的用例之一。 它使您可以以非常低的成本托管整个静态网站。 Amazon S3是高度可用且可扩展的托管解决方案。

Amazon S3 is designed to deliver 99.999999999% durability and scale for trillions of objects worldwide. I would recommend reading our post “Amazon S3 – Simple Storage Service” to get started with Amazon S3. It’s very easy to host a static website on Amazon S3 with very minimal steps. Amazon S3 does not support the server side scripting.

Amazon S3旨在为全球数万亿个对象提供99.999999999%的耐用性和规模。 我建议阅读我们的文章“ Amazon S3 –简单存储服务 ”以开始使用Amazon S3。 使用最少的步骤在Amazon S3上托管静态网站非常容易。 Amazon S3不支持服务器端脚本。

Amazon has other services to store dynamic websites on AWS. You may like to start with “Amazon EC2 – Elastic Compute Cloud” for instance.

亚马逊还有其他服务可在AWS上存储动态网站。 例如,您可能想从“ Amazon EC2 – Elastic Compute Cloud ”开始。

什么是静态网站托管? (What is Static Website Hosting?)

So, what is static web hosting? – static websites only contain static resources like HTML, images, javascript, CSS, and fonts etc. Static web hosting does not contain server-side processing or scripting. In contrast, a dynamic website relies on server-side processing, including server-side scripts such as JSP, PHP, or ASP.NET etc.

那么,什么是静态虚拟主机? –静态网站仅包含HTML,图像,JavaScript,CSS和字体等静态资源。静态网站托管不包含服务器端处理或脚本。 相反,动态网站依赖服务器端处理,包括服务器端脚本,例如JSP,PHP或ASP.NET等。

A static website delivers exactly the same content on each request because pages are stored in file storage. With no dynamic manipulation of content at runtime. Which makes the static website much faster in comparison to the dynamic websites. Most of the Static Website Hosting Platform allows to cache data at large extent.

静态网站会在每个请求上提供完全相同的内容,因为页面存储在文件存储中。 在运行时不对内容进行动态处理。 与动态网站相比,这使静态网站更快。 大多数静态网站托管平台都允许在很大程度上缓存数据。

Please drop the comment if you want us to provide a detailed post on the different type of website hosting on AWS.

如果您希望我们提供有关AWS上不同类型的网站托管的详细信息,请删除评论。

网站端点 (Website Endpoints)

Every website must have a URL or an IP address to access the website over the internet. To host a static website on Amazon S3 you need to create an S3 bucket. And that bucket will have the public read access.

每个网站都必须具有URL或IP地址,才能通过Internet访问该网站。 要在Amazon S3上托管静态网站,您需要创建一个S3存储桶。 该存储桶将具有公共读取权限。

As I explained in my post “Amazon S3 – Simple Storage Service” each bucket on Amazon S3 is unique across all AWS accounts. Also, the bucket name must follow the DNS rules. Hosting a static website requires a bucket to follow the DNS restrictions. Amazon S3 buckets follow the DNS rules so that you can use the same website endpoints.

正如我在文章“ Amazon S3 –简单存储服务 ”中所解释的那样, Amazon S3上的每个存储桶在所有AWS账户中都是唯一的。 此外,存储桶名称必须遵循DNS规则。 托管静态网站需要使用存储区来遵循DNS限制。 Amazon S3存储桶遵循DNS规则,因此您可以使用相同的网站终端节点。

An ideal endpoint on Amazon S3 would look like:

Amazon S3上的理想端点如下所示:

<s3-bucket-name>.s3-website-<AWS-region>.amazonaws.com

OR

要么

<s3-bucket-name>.s3-website.<AWS-region>.amazonaws.com

So, let’s take an example with bucket name “journaldev” in region EU (Paris): eu-west-3 and US East (N. Virginia): us-east-1.

因此,让我们举一个在欧盟(巴黎)地区的桶名称为“ journaldev”的示例:eu-west-3和US East(北弗吉尼亚州):us-east-1

  • These URLs will request to the default index.html in your bucket.
    https://journaldev.s3-website-eu-west-3.amazonaws.com/
    https://journaldev.s3-website-us-east-1.amazonaws.com/

    这些网址将请求存储桶中的默认index.html。
  • These URLs will request to the object aws.png in your bucket.
    https://journaldev.s3-website-eu-west-3.amazonaws.com/aws.png
    https://journaldev.s3-website-us-east-1.amazonaws.com/aws.png

    这些网址将请求您存储桶中的对象aws.png。
  • These URLs will request to post/sample-post.html in your bucket.
    https://journaldev.s3-website-eu-west-3.amazonaws.com/post/sample-post.html
    https://journaldev.s3-website-us-east-1.amazonaws.com/post/sample-post.html

    这些URL将请求在您的存储桶中发布post / sample-post.html。

You can also use a custom domain (For Example – https://example-sample-domain.com/) to point to your Static Website on Amazon S3.

您还可以使用自定义域(例如– https://example-sample-domain.com/ )指向Amazon S3上的静态网站。

在Amazon S3上托管静态网站 (Hosting Static Website on Amazon S3)

Static Website will be hosted in Amazon S3 bucket. For those who don’t know how to create a bucket, let’s get started with creating one.

静态网站将托管在Amazon S3存储桶中。 对于那些不知道如何创建存储桶的人,让我们开始创建一个存储桶。

步骤1:建立值区 (Step 1: Create Bucket)

Go to the Amazon S3 from the service tab and click on the link.

从服务选项卡转到Amazon S3,然后单击链接。

Follow the onscreen instruction OR read the steps in the post “Amazon S3 – Simple Storage Service” given under the heading “Create S3 Bucket”. Once you are done with the bucket creation, you will see the below screen.

按照屏幕上的说明进行操作,或阅读标题为“创建S3存储桶”下的“ Amazon S3 –简单存储服务”中的步骤。 完成存储桶创建后,您将看到以下屏幕。

步骤2:启用网站托管 (Step 2: Enable website hosting)

Your default bucket is not web hosting enabled. Follow the steps below to enable web hosting for your bucket:

您的默认存储桶未启用网络托管。 请按照以下步骤为您的存储桶启用网络托管:

  1. You are already signed in and at Amazon S3 console https://console.aws.amazon.com/s3/.

    您已经登录并在Amazon S3控制台https://console.aws.amazon.com/s3/上 。
  2. Select your bucket that you want to choose to host your static website. In our case it’s “journaldev”.

    选择您要选择用来托管静态网站的存储桶。 在我们的例子中是“ journaldev”
  3. Click on the properties tab.

    单击属性选项卡。
  4. Click on option “Static website hosting” and then choose “Use this bucket to host a website”.

    单击选项“静态网站托管” ,然后选择“使用此存储桶托管网站”
  5. You will be prompted with the screen to set index file and error documents.

    屏幕上将提示您设置索引文件和错误文档。

Step 1:

Static Web Hosting Option

第1步:

Step 2:

Static Webhosting Select Card

第2步:

Click on the panel above and you will see the below screen with three options. Click on radio button marked with red.

Static Web Hosting Select Options

单击上方的面板,您将看到以下带有三个选项的屏幕。 单击标有红色的单选按钮。

步骤3:索引文档和文件夹 (Step 3: Index Documents and Folders)

As in most of the static website index document is the web page which appears when a user requests the home URL. For example, if your site URL is “https://example-sample-domain.com/” then on browsing this user did not ask for a specific page. Amazon S3 will serve the index document in this case.

与大多数静态网站索引文档一样,网页是用户请求家庭URL时显示的网页。 例如,如果您的站点URL是“ https://example-sample-domain.com/ ”,那么在浏览该用户时并不需要特定的页面。 在这种情况下,Amazon S3将提供索引文件。

So, let’s assume that index.html is your index document. The trailing slash at the root-level URL is optional. For example, if you configure your website with index.html as the index document, either of the following two URLs returns index.html.

因此,假设index.html是您的索引文档。 根级别URL的斜杠是可选的。 例如,如果使用index.html作为索引文档配置网站,则以下两个URL之一将返回index.html。

  1. https://example-sample-domain.com

    https://example-sample-domain.com
  2. https://example-sample-domain.com/index.html

    https://example-sample-domain.com/index.html

步骤4:配置错误 (Step 4: Configuring Errors)

You can configure the error page at the time of enabling the static website hosting. For custom error pages you can set the redirection rules. For your website you can create error pages for the below https codes:

您可以在启用静态网站托管时配置错误页面。 对于自定义错误页面,您可以设置重定向规则。 对于您的网站,您可以为以下https代码创建错误页面:

  1. 301 – Moved Permanently

    301 –永久移动
  2. 400 – Malformed Request

    400 –格式错误的请求
  3. 403 – Access Forbidden

    403 –禁止访问
  4. 404 – Page not found

    404页面不存在
  5. 500 – Service Error

    500 –服务错误
  6. 503 – Service not available

    503 –服务不可用

You can create a page for each of these errors and set the redirection rule. See how to set the redirection rules in below section.

您可以为每个错误创建一个页面并设置重定向规则。 请参阅以下部分,如何设置重定向规则。

步骤5:网站访问权限 (Step 5: Website Access Permission)

This is one of the very important parts of the Amazon S3 hosting. You have to change the bucket access permission. Let’s check the URL without setting up the permissions, you will see below page:

这是Amazon S3托管的非常重要的部分之一。 您必须更改存储桶访问权限。 让我们在不设置权限的情况下检查URL,您将看到以下页面:

Now, let’s add the permission to allows public access of your bucket.

现在,让我们添加权限以允许您的存储桶公开访问。

Copy and paste below json object to your bucket policy editor and save it. See the screen below the code:

将json对象下面的内容复制并粘贴到存储桶策略编辑器中并保存。 请参见代码下方的屏幕:

{"Version": "2019-02-15","Statement": [{"Sid": "AllowPublicRead","Effect": "Allow","Principal": {"AWS": "*"},"Action": "s3:GetObject","Resource": "arn:aws:s3:::journaldev/*"}]
}

See the below screen, now your bucket has public access.

请参阅下面的屏幕,现在您的存储桶可以公开访问了。

步骤6:流量记录 (Step 6: Traffic Logging)

Click on the bucket properties and you will see the below screen.

单击存储桶属性,您将看到以下屏幕。

This will log each and every request coming to your website. It’s typically the HTTP access logs. If you are familiar with any of the web server then you can relate to the web server access logs.

这将记录进入您网站的每个请求。 通常是HTTP访问日志。 如果您熟悉任何Web服务器,则可以与Web服务器访问日志相关。

页面重定向 (Redirection of pages)

Redirection is the property through which you can change the destination page based on the rules. You can use redirection of pages for several use cases like:

重定向是可用于根据规则更改目标页面的属性。 您可以将页面重定向用于以下几种用例:

  1. Setting up the error pages based on http error code

    根据http错误代码设置错误页面
  2. Send certain types of request to a page

    将某些类型的请求发送到页面
  3. Send to a page for all unknown urls

    发送到所有未知网址的页面
  4. Open other pages

    打开其他页面

It really depends on what you want. Just to show you i tried to redirect the sample-post.html page to the home page i.e. index.html.

这实际上取决于您想要什么。 只是为了向您展示,我尝试将sample-post.html页面重定向到主页,即index.html

测试您的静态网站 (Testing Your Static Website)

Now, the moment of the truth. Let’s execute the test cases one by one.

现在,关键时刻。 让我们一一执行测试用例。

Test Case 1: Do not make the bucket public and browse the bucket URL and see whether the website is opening or not. The expected result is that access should be forbidden.

Access Forbidden

测试案例1:不要公开存储桶,而是浏览存储桶URL并查看网站是否正在打开。 预期结果是应禁止访问。

Test Case 2: Remove or do not upload the index.html file which is the index document of our website. The expected result is that we will get a 404 error.html page in response.

404 Not Found Page

测试案例2:删除或不上传index.html文件,该文件是我们网站的索引文件。 预期结果是我们将得到一个404 error.html页面作为响应。

Test Case 3: Add a folder post and add a sample-post.html. Just upload the page and browse the Url. The expected result is page should open in the browser.

Sample Post Page

测试案例3:添加文件夹帖子并添加sample-post.html。 只需上传页面并浏览网址。 预期结果是应在浏览器中打开页面。

Your static website is live on Amazon S3. In our next topic, we will post how you can host a website with a custom domain.

您的静态网站位于Amazon S3上。 在下一个主题中,我们将发布如何托管具有自定义域的网站。

翻译自: https://www.journaldev.com/25781/hosting-static-website-on-amazon-s3

amazon s3

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_712902.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一个可以实时查相关电子产品价格的网站

香港价格网&#xff0c;里面的价格和香港的百老汇、丰泽等的价格几乎同步&#xff0c;相差不大&#xff0c;有很大的参考价值&#xff0c;对于准备去香港买电子产品的网友来说&#xff0c;是个非常好的网站&#xff0c;特别分享&#xff1a; http://www.price.com.hk/转载于:ht…

简单高效!25个漂亮的简约风格网站设计作品

在过去几年里&#xff0c;网站设计领域发生了巨大变化。除了 RWD&#xff08;响应式网页设计&#xff09;和 Web 字体的革命&#xff0c;现代设计的发展趋势迅速流行扁平化的配色方案&#xff0c;网页排版变得更加重要&#xff0c;重点已放在内容第一。最后&#xff0c;页面加载…

增城seo搜索引擎优化_搜索引擎seo优化主要从哪里入手?

首先我们应该了解什么是搜索引擎优化以及网站搜索引擎seo优化的价值&#xff0c;从基础开始逐步深入&#xff0c;下面拓王朝所要讲的都是一些理论知识&#xff0c;很好理解&#xff0c;有不同见解欢迎评论。SEO优化SEO搜索引擎优化&#xff0c;是指通过采用易于搜索引擎索引和排…

[转]使用ThinkPHP框架快速开发网站(多图)

本文转自&#xff1a;http://blog.csdn.net/ruby97/article/details/7574851 这一周一直忙于做实验室的网站&#xff0c;基本功能算是完成了。比较有收获的是大概了解了ThinkPHP框架。写一些东西留作纪念吧。如果对于同样是Web方面新手的你有一丝丝帮助&#xff0c;那就更好了挖…

《大型网站技术架构》读书笔记[3] - 架构核心五要素

架构设计中要考虑的核心五要素&#xff1b; 性能、可用性、扩展性、伸缩性、安全性 性能 性能的测试指标 响应时间 应用执行一个操作需要的时间&#xff0c;包括从发出请求开始到收到最后响应数据所需要的时间。响应时间是系统最重要的性能指标&#xff0c;直观地反映了系统的“…

java抓取网页数据_Golang丨Java丨Python爬虫实战—Boss直聘网站数据抓取

我们分别通过Golang、Python、Java三门语言&#xff0c;分别实现对Boss直聘网站的招聘数据进行爬取。首先打开Boss直聘网站&#xff1a;然后我们在职位类型中输入Go或者Golang关键字&#xff1a;然后我们可以看到一个列表&#xff0c;和Go语言相关的各种招聘职位&#xff0c;还…

我的网站被黑了,关键词被劫持,总结一下是怎么解决的。

1、发现被黑&#xff0c;网站被黑的症状 两年前自己用wordpress搭了一个网站&#xff0c;平时没事写写文章玩玩。但是前些日子&#xff0c;突然发现网站的流量突然变小&#xff0c;site了一下百度收录&#xff0c;发现出了大问题&#xff0c;网站被黑了。大多数百度抓取收录的页…

一个大图切成几个小图加载速度更快_谷歌SEO页面速度的重要性

什么是页面速度&#xff1f;页面速度是指网页加载所需的时间。一个页面的加载速度是由几个不同的因素决定的&#xff0c;包括网站的服务器、页面文件大小和图片压缩。也就是说&#xff0c;"页面速度 "并不像 "网页速度 "那么重要。"页面速度 "并…

大学计算机思维导图_3款免费在线思维导图网站,你一定要收藏一个!

1&#xff1a;迅捷画图https://www.liuchengtu.com/迅捷画图是一个专业的思维导图、流程图制作网站。支持在线创作流程图、思维导图、组织结构、ER图、网络拓扑图、UML图等等。接下来说说特色&#xff1a;l 支持导出多种格式&#xff0c;如JPG、PNG、PDF文件、txt文本等格式l 提…

python中data.find_all爬取网站为空列表_利用Golang快速爬取盗版网站的整套音频

01前言最近因为 Zigma 帮我写了个推广 Catcher 小程序软文的原因&#xff0c;答应了他帮他爬了一个盗版音频网站的整套 《李淼谈奇案》 。在制作爬虫脚本的过程中&#xff0c;也是遇到了一些有趣的问题&#xff0c;所以特此写了这篇 Blog 用于记录脚本的整一个实现与问题解决。…

java web 项目伪静态_【Java Web】使用URLRewrite实现网站伪静态

大部分搜索引擎都会优先考虑收录静态的HTML页面&#xff0c;而不是动态的*.jsp、*.php页面。但实际上绝大部分网站都是动态的&#xff0c;不可能全部是静态的HTML页面&#xff0c;因此互联网上大部分网站都会考虑伪静态——就是将*.jsp、*.php这种动态URL伪装成静态的HTML页面。…

网站html静态化 教程,新云CMS网站内容管理系统生成HTML静态化教程

网站静态化一直是SEO重点关注对象。静态化有好有坏&#xff0c;最大的好处是收录迅速&#xff0c;坏处是纯静态的HTML页面难以维护&#xff0c;特别是对于大型的网站。本文将介绍如何将新云CMS网站管理系统静态化。html本文以新云CMS 3.0为例。动画1.进入后台控制面板&#xff…

ASP.NET SignalR 与LayIM配合,轻松实现网站客服聊天室(四) 添加表情、群聊功能...

休息了两天&#xff0c;还是决定把这个尾巴给收了。本篇是最后一篇&#xff0c;也算是草草收尾吧。今天要加上表情功能和群聊。基本上就差不多了&#xff0c;其他功能&#xff0c;读者可以自行扩展或者优化。至于我写的代码方面&#xff0c;自己也没去重构。好的&#xff0c;我…

苹果cms mysql 什么版本_分享如何使用阿里云ECS快速搭建CMS网站

想建网站又不会编程的小伙伴有福啦&#xff0c;本期推荐一些开源的cms建站程序&#xff0c;不需要写后端的任何逻辑代码&#xff0c;轻轻松松就可以建立自己的网站了&#xff0c;当然&#xff0c;要想网站有自己的个性&#xff0c;模版还是需要自己写的&#xff0c;只需要会简单…

关于大型网站技术演进的思考(一)--存储的瓶颈(1)

前不久公司请来了位互联网界的技术大牛跟我们做了一次大型网站架构的培训&#xff0c;两天12个小时信息量非常大&#xff0c;知识的广度和难度也非常大&#xff0c;培训完后我很难完整理出全部听到的知识&#xff0c;今天我换了个思路是回味这次培训&#xff0c;这个思路就是通…

动易html在线编辑器 漏洞,动易系统解决IE8网站后台编辑器无效问题

微软的IE8正式版已于2009年3月20日正式发布了&#xff0c;也有不少的动易用户升级了自己的浏览器&#xff0c;但在升级后都发现动易的后台编辑器无法使用了&#xff0c;症状就是点击任何功能图标都没有弹出设置窗口&#xff0c;经过搜索了一下&#xff0c;终于找到了解决IE8下无…

seo 伪原创_seo文章优化(怎么样做好伪原创文章)

在seo网站优化行业中有很大一部分的站点都是以做内容为主&#xff0c;做内容的重点就是写文章&#xff0c;因为很多在搜索引擎中的排名都是靠文章的&#xff0c;那么我们就要着重做好文章&#xff0c;目前还是有很大一部分在做文章的步骤中的问题很大&#xff0c;就是因为没有掌…

apache 网站转nginx_堡塔网站加速宝塔面板网站加速安装设置使用教程

堡塔网站加速是宝塔面板为用户开发的一款网站加速插件&#xff0c;基于页面缓存的网站加速插件&#xff0c;支持常见的众多建站程序加速。其原理是在http协议层缓存动态页面&#xff0c;对实时信息及已登录的会话跳出缓存&#xff0c;此技术主要针对匿名访问的用户进行加速响应…

java音乐网站源码_Vue + SpringBoot + MyBatis 音乐网站

一、前言这里对音乐网站这个项目的开发流程做一下描述&#xff0c;我觉得了解了具体实现的来龙去脉&#xff0c;上手自己做就容易得多了&#xff0c;要知道数据是怎么从数据库一步步跑到前端页面的&#xff0c;当知道了整个的流程再去处理中间的细节&#xff0c;具体实现的细节…

网站导航颜色停留_提高网站流量的方法有哪些?

在做网站SEO推广的时候&#xff0c;网站的访问量是十分重要的一个因素&#xff0c;不仅仅是对网站&#xff0c;对搜索引擎来说也是评价网站级别重要的一个参考因素。那么&#xff0c;提升网站流量的方法有哪些&#xff1f;接下来蜘蛛池博客小编就跟大家分享下提升网站流量的方法…