如何在aws部署web网站_在AWS Part 2b上部署快速安全的Web App:网站设置

news/2024/5/17 5:49:42/文章来源:https://blog.csdn.net/weixin_26742939/article/details/108515646

如何在aws部署web网站

We have been telling too many theoretical stories in Part 1a, 1b, and 2a of this series. It is time to get our hands dirty and start the action we have been teasing with for too long. From this point, we will be setting up a scalable website. The setup will be in two modes. The infrastructure will be set up using Terraform and it will be set up using the AWS Console. At the end of this piece, you will be able to create a static website in Amazon S3.

在本系列的第1a,1b和2a部分中,我们讲了太多的理论故事。 现在是时候弄脏我们的手,并开始进行我们为时已久的戏弄了。 至此,我们将建立一个可扩展的网站。 设置将有两种模式。 该基础设施将使用Terraform进行设置,并将使用AWS控制台进行设置。 在本文的最后,您将能够在Amazon S3中创建一个静态网站。

Let us BeginThe first stage here is to set up the Amazon S3 bucket, which serves two purposes:

让我们开始吧这里的第一步是设置Amazon S3存储桶,它有两个作用:

  1. The location to save the website files (HTML, CSS, and Javascript) files

    网站文件(HTML,CSS和Javascript)文件的保存位置
  2. The webserver to serve the website files on the browser. Like every other web server out there; Apache or Nginx.

    用于在浏览器上提供网站文件的Web服务器。 像其他所有Web服务器一样; Apache或Nginx。

The first step is to ensure you have an AWS account. Go to https://portal.aws.amazon.com/billing/signup#/start. The signup process is free, though you will be asked to provide your card details. We will ensure we keep the cost of running this website to the barest minimum, so we do not incur any significant cost to host this website.

第一步是确保您拥有一个AWS账户。 转到https://portal.aws.amazon.com/billing/signup#/start 。 注册过程是免费的,但是会要求您提供卡的详细信息。 我们将确保将本网站的运营成本保持在最低水平,因此我们不会为托管该网站带来任何可观的费用。

When the AWS account is activated, login to the AWS Console.

激活AWS帐户后,登录到AWS控制台。

Image for post
AWS Console
AWS控制台

The figure above is the page we land on when the login is successful. It shows the list of AWS services. Our focus is to create an S3 bucket to host our website. We will create the bucket and write a simple HTML website and upload it to the S3 bucket.

上图是登录成功后进入的页面。 它显示了AWS服务列表。 我们的重点是创建一个S3存储桶以托管我们的网站。 我们将创建存储桶并编写一个简单HTML网站,并将其上传到S3存储桶。

Creating the S3 BucketTo create the S3 bucket, search for S3 on the AWS Management Console.

创建S3存储桶要创建S3存储桶,请在AWS管理控制台上搜索S3。

Image for post
AWS Management Console
AWS管理控制台

Click on the S3 link to load the Amazon S3 console.

单击S3链接以加载Amazon S3控制台。

Image for post
S3 Management Console
S3管理控制台

The S3 Management console shows the list of existing buckets and an option to create new buckets. To create a bucket, click on the Create Bucket button. To create the bucket, then type the name of the bucket.

S3管理控制台显示现有存储桶的列表以及创建新存储桶的选项。 要创建存储桶,请单击创建存储桶按钮。 要创建存储桶,然后输入存储桶的名称。

Image for post
Create S3 Bucket
创建S3存储桶

Ensure the name of the bucket is the same as the domain name for the website. For example; if the domain name is scrapersloung.io, then the bucket name must be mcsseries.io. S3 buckets also support sub-domains, so you can host, a subdomain on S3, but it has to be in a different bucket and not the same bucket where the domain was created. After typing the name of the bucket; click on the Create button.

确保存储桶的名称与网站的域名相同。 例如; 如果域名是scrapersloung.io,然后桶名称必须是mcsseries.io。 S3存储桶还支持子域,因此您可以在S3上托管一个子域,但是它必须位于不同的存储桶中,而不能与创建域的存储桶相同。 键入存储桶的名称后; 单击创建按钮。

Imputation of S3 Bucket Name
Imputation of Bucket Name
桶名称的插补

The create button will then create the bucket and it becomes visible as one of the lists of buckets.

然后,创建按钮将创建存储桶,并显示为存储桶列表之一。

S3 Bucket Created Successfully
Bucket Created Successfully
桶创建成功

Configure the Bucket as a WebsiteNow that the bucket has been created successfully, the next stage is to make the bucket a website. An S3 bucket is primarily designed to store files/objects with unlimited storage. But we are using it for a website. So we need to go ahead and make the bucket a website which is what we are configuring it for. To do that, click on the bucket that was just created. This will take us to the Overview of the bucket and giving options to other tabs, such as the Properties, Permissions, Management, and Access Points.

将存储桶配置为网站既然已经成功创建了存储桶,下一步就是将存储桶设为网站。 S3存储桶主要用于存储无限存储的文件/对象。 但是我们正在将它用于网站。 因此,我们需要继续进行操作,并使存储桶成为我们正在为其配置的网站。 为此,请单击刚刚创建的存储桶。 这将带我们进入“存储桶概述 ”,并为其他选项卡提供选项,例如“ 属性”,“权限”,“管理”和“ 访问点”。

S3 Bucket Overview Page
S3 Bucket Overview Page
S3铲斗概述页面

The focus here is on the Properties tab. This is where the bucket configurations are made to make the bucket become a website. Click on the Properties tab. The Properties tab is made up of different options.

此处的焦点位于“ 属性”选项卡上。 在此处进行存储桶配置以使存储桶成为网站。 单击属性选项卡。 “属性”选项卡由不同的选项组成。

S3 Bucket Properties Page
S3 Bucket Properties Page
S3存储桶属性页面

The option we need out of all is the Static website hosting. Click on the Static website hosting option to configure the website.

我们首先需要的选项是静态网站托管。 单击静态网站托管选项以配置网站。

Activating Amazon S3 website
Activating S3 Website
激活S3网站

Click on the option Use this bucket to host a website.

单击选项使用此存储桶托管网站。

Image for post

The first box is labeled, is Index document, which should specify the home page of the website, which is usually index.html by default. Simply input index.html. There is also the Error document, which is quite not compulsory, so it will be left blank. Click the Save button to save these changes. Take note of the URL of the bucket, that is the URL we will be using to visit our website when it has been uploaded/deployed. For this example, the URL is: http://mcsseries.io.s3-website.us-east-2.amazonaws.com

第一个框被标记为索引文档,文档应指定网站的主页,默认情况下通常为index.html。 只需输入index.html。 还有一个Error文档 ,它不是强制性的,因此将留为空白。 单击保存按钮以保存这些更改。 记下存储桶的URL,即在上载/部署后将用于访问我们网站的URL。 对于此示例,URL为: http : //mcsseries.io.s3-website.us-east-2.amazonaws.com

Making Bucket Public for Internet AccessDue to the fact that this is a website, hosted in S3 and need to be accessed over the internet, we have to make the bucket public and the objects in the bucket public. To do that, click on the Permissions tab. The default item selected is Block public access. On the screen, click on the Edit button.

将存储桶公开以供Internet访问由于这是一个托管在S3中的网站,需要通过Internet进行访问,因此我们必须将存储桶公开,并将存储桶中的对象公开。 为此,请单击“ 权限”选项卡。 选择的默认项是“ 阻止公共访问”。 在屏幕上,单击“ 编辑”按钮。

Edit S3 Bucket Public Access
Edit S3 Access
编辑S3访问

Uncheck the first item in the list with the label Block all public access. To give the bucket public access. Click the Save button to save the change. This will show the pop-up to confirm the changes that have been saved.

取消选中标签为禁止所有公共访问的列表中的第一项 授予存储桶公共访问权限。 单击保存按钮以保存更改。 这将显示弹出窗口,以确认已保存的更改。

Image for post

Type confirm in the box and click the Confirm button to confirm the changes that have been made.

在框中键入确认,然后单击确认按钮以确认所做的更改。

N.B. The only reason this bucket is made public is that it is a website. When you create an S3 bucket, for storing more sensitive objects, it is advisable to keep it private to avoid access over the public internet. See more here.

注意 :此存储桶公开的唯一原因是它是一个网站。 创建S3存储桶时,为了存储更多敏感对象,建议将其保密,以避免通过公共Internet进行访问。 在这里查看更多。

The other public access that needs to be configured is on the Bucket Policy. This policy is used for objects inside the bucket. The policy is generated using the Policy Generator link at the bottom of the page. We have generated a bucket policy and it looks like this.

需要配置的其他公共访问权限在存储桶策略中 。 此策略用于存储桶中的对象。 该策略是使用页面底部的“ 策略生成器”链接生成的。 我们已经生成了一个存储桶策略,它看起来像这样。

{"Id": "Policy1596477460393","Version": "2012-10-17","Statement": [{"Sid": "Stmt1596477458210","Action": "s3:*","Effect": "Allow","Resource": "arn:aws:s3:::mcsseries.io/*","Principal": "*"}]
}

The most important part of the policy is the Resource part, change the last values to your specific Resource. The item arn:aws:s3:::mcsseries.io/*. What changes is the bucket name, which in this example is mcsseries.io. Ensure to change for yours when doing your configuration. It has to always be the name of the bucket.

该策略最重要的部分是“ 资源”部分,将最后一个值更改为您的特定“资源”。 项arn:aws:s3 ::: mcsseries.io/*。 更改的是存储桶名称,在此示例中为mcsseries.io。 在进行配置时,请确保根据您的情况进行更改。 它必须始终是存储桶的名称。

Paste it in the Bucket policy editor and click the Save button.

将其粘贴到存储桶策略编辑器中 ,然后单击“ 保存”按钮。

Image for post

This will make all the objects in the bucket to be publicly accessible.

这将使存储桶中的所有对象都可以公开访问。

Uploading/Deploying our WebsiteNow that the bucket is ready and has been configured to be a website, the next step is to upload our website. S3 for web hosting hosts HTML, CSS, and Javascript websites. Apps build with Angular, React and Vue can be hosted in S3. For this simple example, I will be using a very simple HTML file for demonstration.

上载/部署我们的网站既然存储桶已经准备好并将其配置为网站,下一步就是上载我们的网站。 用于Web托管的S3托管HTML,CSS和Javascript网站。 可以在S3中托管使用​​Angular,React和Vue构建的应用程序。 对于这个简单的示例,我将使用一个非常简单HTML文件进行演示。

<html><h1>Welcome to a static S3 website</h2>
</html>

This HTML file will be uploaded into the S3 bucket. To do that, click on the Overview tab which is the first tab we landed on initially. Click on the Upload button on the top menu bar, just below the Overview tab.

该HTML文件将被上传到S3存储桶中。 为此,请单击“ 概述”选项卡,这是我们最初登陆的第一个选项卡。 单击顶部菜单栏上“概述”选项卡正下方的“上载”按钮。

Image for post

This will launch the pop-up to allow for uploading the HTML file

这将启动弹出窗口,以允许上传HTML文件

Image for post

You can either drag the file from the directory it is saved, into the screen, or click the Add files, button to add the file to the list of what needs to be uploaded.

您可以将文件从保存目录拖到屏幕上,也可以单击添加文件按钮将文件添加到需要上传内容的列表中。

Image for post

Click on the Upload button to upload the file.

单击上按钮以上传文件。

Image for post

Click on the URL shared earlier to view the uploaded website: http://mcsseries.io.s3-website.us-east-2.amazonaws.com. This will reveal the website.

单击先前共享的URL,以查看上载的网站: http : //mcsseries.io.s3-website.us-east-2.amazonaws.com 。 这将显示该网站。

ConclusionThis is the first step in getting your website up. With this setup, there are no servers to manage and the website scales almost infinitely. You can always upload a more complex proper web page, as I used a simple web page to demonstrate this example. Next up is how to attach caching to this website and speed it up. Stay Tuned

结论这是建立您的网站的第一步。 使用此设置,无需管理服务器,并且网站几乎可以无限扩展。 您总是可以上传更复杂的适当网页,因为我使用一个简单的网页来演示此示例。 接下来是如何将缓存附加到该网站并加快速度。 敬请关注

MyCloudSeries is a training and consulting firm with expertise in Cloud Computing and DevOps. We assist organizations in their DevOps strategies, transformation, and implementation. We also provide Cloud Computing Support contact us at www.mycloudseries.com

MyCloudSeries是一家培训和咨询公司,在云计算和DevOps方面具有专业知识。 我们协助组织进行DevOps战略,转型和实施。 我们还提供云计算支持,请访问www.mycloudseries.com与我们联系。

翻译自: https://medium.com/mycloudseries/deploying-fast-and-secure-web-app-on-part-2b-website-setup-60de2effc683

如何在aws部署web网站

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

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

相关文章

网站会员整合ucenter 实现多站点同步登录方法

之前简单的写过一篇的用户注册整合ucenter的文章&#xff0c;因为写的很简洁&#xff0c;很多童鞋都看的不是很明白&#xff0c;也收到了很多童鞋的问题邮件。前几天因为公司的几个 网站需要做同步登录功能&#xff0c;因此就用到了ucenter作为中间桥梁。现在很多开源的cms系统…

VS2012发布网站

一、在VS中生成网站源文件 项目完成后&#xff0c;右键自己创建的web项目&#xff0c;点击‘发布’。之后出现‘发布web’界面&#xff0c;其中包括配置文件&#xff0c;连接&#xff0c;设置&#xff0c;预览四个子选项。 首先在出现的配置文件中&#xff0c;在选择或导入发布…

通过避免下列 10 个常见 ASP.NET 缺陷使网站平稳运行

本文将讨论&#xff1a; • 缓存和 Forms 身份验证 • 视图状态和会话状态 • 配置文件属性序列化 • 线程池饱和 • 模拟和设置配置文件 本文使用了下列技术&#xff1a; .NET Framework、ASP.NET、Windows Server 2003 本页内容 LoadControl 和输出缓存会话和输出缓…

DomoloSEOHelper 多么乐SEO助手 预览版发布啦

DomoloSEOHelper 多么乐SEO助手 预览版发布啦 装修是一件烦人的事情&#xff0c;但能亲手参与一次&#xff0c;还是值得的---题记 漫长的装修工程终于结束了。装修的时候最好奇的还是&#xff0c;看到泥工、瓦工、油工的 工具箱 toolkit。有了各式各样的工具&#xff0c;木板、…

Domolo SEOHelper 多么乐SEO工具:璀璨登场

Domolo SEOHelper 多么乐SEO工具&#xff1a;璀璨登场 六大功能&#xff1a;1、PageRank 批量查询 &#xff0c; 现在的工具只能查一个网页&#xff0c;没有批量查询&#xff0c;现在您可以批量查询了&#xff1b;2、网站 keywords , description , title 收割机&#xff0c; …

基于SEO的Log 日志分析软件应该提供那些功能?

基于SEO的Log 日志分析软件应该提供那些功能? 今天是连续第3个要过了12点才睡的日子了&#xff0c;希望今天可以告一个段落&#xff0e; 最近在考虑如何做基于 SEO 的日志分析工具, 每天都熬夜, 还真吃不消啊.当用户在浏览器地址栏输入一个网址的时候,web服务器在返回用户需要…

搜索引擎SEO外挂:一边搜索,一边看PageRank

搜索引擎SEO外挂&#xff1a;一边搜索&#xff0c;一边看PageRank 下载地址&#xff1a;多么乐站长工具 我原来曾写过一篇统计分析搜索引擎排名和Page Rank 关联分析 的文章。很多人引用&#xff0c;回复和我讨论了我的结论。有赞成的&#xff0c;有反对的&#xff0c;有鼓励…

SEO 比比看: Che168.com VS pcauto.com.cn

SEO 比比看&#xff1a; Che168.com VS pcauto.com.cn 做SEO工作&#xff0c;平常少不了多观察各种网站优化的案例。俗话说的好&#xff0c;懂行的看门道&#xff0c;不懂的看热闹。面对五花八门的网站&#xff0c;如何才能从专家的角度&#xff0c;以最快的速度来了解被观察网…

seo优化:把百度放进数据库

seo优化:把百度放进数据库 有时候我想&#xff0c;能把百度的数据放进数据库&#xff0c;用广大程序员熟悉的sql语句查询百度的搜索结果应该是一个不错的主意。在这方面Google早已经跨出了一大步&#xff0c;利用Google Search API 把Google的搜索结果放进数据库是很容易办到得…

PO模式+数据驱动(TPshop网站的登录模块进行单元测试以及区分正向逆向用例)

一、区分正向逆向用例 思路&#xff1a;在测试数据中添加一一个标识正向用例或逆向用例的标记&#xff1a;如&#xff1a;True/False 步骤&#xff1a; 调用登录方法(此登录方法中&#xff0c;只有输入用户名、输入密码、输入验证码、 点击登录按钮)判断用例标记&#xff1a;…

推荐一些网站给大家

推荐一些网站给大家 首先要隆重推荐http://www.moreofit.com/ 这个网站可以发现跟你输入网站类似的网站&#xff0c;如我们在地址栏中输入博客园的地址http://www.cnblogs.com/&#xff0c; 点击查看&#xff0c;系统会列出和博客园类似的网站&#xff0c;没准你会发现很多有意…

一篇文章学会独立在Windows server 2003虚拟机上搭建网站

本文学习&#xff1a;在Windows server 2003 虚拟机上的服务器搭建一个网站&#xff0c;非常详细&#xff0c;我都会了真的&#xff0c;有手就行。 Windowsiisaspaccess 环境&#xff1a;一台windows server 2003虚拟机。 准备工作什么也没有&#xff0c;开始搭建 开始测试搭建…

*.github.io的个人博客网站无法连接的问题

问题描述 就是这个样子的&#xff0c;类似*.github.io的网站都打不开&#xff0c;而且是手机电脑连接同一个WIFI&#xff0c;都打不开&#xff0c;但是我手机换了数据&#xff0c;就可以打开了&#xff0c;也是很奇怪&#xff0c;突然就这样了&#xff0c;我也不知道怎么回事&a…

Python多进程之刷小网站浏览量。

作者刚入门Python爬虫&#xff0c;如代码有问题&#xff0c;请大佬评论区指出&#xff01;&#xff01; 代码实现&#xff1a; 1&#xff0c;通过multiprocessing中的进程池实现多进程爬虫。 2&#xff0c;通过requests发起get请求刷浏览量。 代码&#xff1a; from multipr…

爬了招聘网站之后,总结Python学习的几点建议

来源商业新知网&#xff0c;原标题&#xff1a;&#xff1a;爬了招聘网站之后&#xff0c;给你几点学习Python的建议 Python语言相关的岗位非常多&#xff0c;有运维&#xff0c;有自动化测试&#xff0c;有后端开发&#xff0c;有机器学习&#xff0c;如果想要快速上手&#x…

点击链接自动定位到网页某个具体位置和网站右侧导航介绍

页面点击链接后&#xff0c;自动定位到网页某个具体位置 <!DOCTYPE html> <html> <head> <meta http-equiv"Content-Type" content"text/html; charsetutf-8" /> <title>test</title> </head> <body> …

大型网站架构提速关键技术(页面静态化、memcached、Mysql优化)

大型网站关键技术介绍 1. pv值(page views),访问量大 带来问题 a. 流量大 10000000*2m ->解决方案 买带宽 ,优化程序(处理图片) b. 并发量,同时访问网站的人多.,解决方案 对程序的架构重新设计.->服务器集群 示意图: 1. 数据量大->10亿记录 解决方法是 a. 表的…

问答网站Quora副总裁杨蕾博士:让知识改变世界

????点击上方蓝字星标“Robinly”&#xff0c;获取更多重磅AI访谈 Robin.ly 是立足硅谷的视频内容平台&#xff0c;服务全球工程师和研究人员&#xff0c;通过与知名人工智能科学家、创业者、投资人和领导者的深度对话和现场交流活动&#xff0c;传播行业动态和商业技能&am…

Nginx对某个目录或整个网站进行登录认证的方法

比如要对 网站目录下的 test 文件夹 进行加密认证 首先需要在opt 的主目录中 /opt/ 创建一个新文件 htpasswd 此文件的书写格式是 用户名:密码 每行一个账户 并且 密码必须使用函数 crypt(3) 加密 官方档说 可以用 Apache 的 htpasswd 工具来创建密码文件 [rootlocalhost /]#…

网站分析基础概念之访问停留时间

类型&#xff1a;计数度量 定义&#xff1a;访问停留时间&#xff08;Visit Duration&#xff09;是指一次访问的持续时间。典型的计算方法是在一次访问中&#xff0c;用户最后一次操作发生的时间减去第一次操作发生的时间。 扩展&#xff1a; ● FAQ&#xff1a;为什么访问停留…