亚马逊 各国站点 链接_使用Amazon S3和HTTPS的简单站点托管

亚马逊 各国站点 链接

by Georgia Nola

乔治亚·诺拉(Georgia Nola)

使用Amazon S3和HTTPS的简单站点托管 (Simple site hosting with Amazon S3 and HTTPS)

Hiya folks!

大家好!

In this tutorial I’ll show you how to host a static website with HTTPS on AWS with a custom domain. All this is possible using AWS free tier.

在本教程中,我将向您展示如何在具有自定义域的AWS上使用HTTPS托管静态网站。 使用AWS免费套餐可以实现所有这些功能。

However, the services we are going to use do incur some small charges. Generally speaking these shouldn’t exceed $1/month.

但是,我们将要使用的服务确实会收取少量费用。 一般来说,这些费用不应超过$ 1 /每月。

We’ll be using a combination of the following AWS services: —S3 — Route53 — Certificate manager— CloudFront

我们将结合使用以下AWS服务:-S3-Route53-证书管理器-CloudFront

Let’s get into it!

让我们开始吧!

设置您的S3存储桶 (Setup your S3 buckets)

First, you’ll need two S3 buckets, both should match your custom domain name with the second including the www subdomain.

首先,您需要两个S3存储桶 ,两个存储桶都应与您的自定义域名匹配,第二个存储桶应与www子域匹配。

Bucket 1: mywebsite.comBucket 2: www.mywebsite.com

值区1: 时段2: www.mywebsite.com

The first bucket (mywebsite.com) is the main bucket for your site. This contains all your files and assets for your static website.

第一个存储桶(mywebsite.com)是您网站的主要存储桶。 其中包含您静态网站的所有文件和资产。

Next we setup this bucket for static site hosting. You can find this under the Properties tab of the bucket, and we’re going to keep the defaults provided here with the index of the site set to index.html.

接下来,我们为静态站点托管设置此存储桶。 您可以在存储桶的“属性”标签下找到此文件,我们将保留此处提供的默认值,并将网站的索引设置为index.html。

We also need to make this bucket publicly accessible as a user’s browser will need to access the bucket’s files in order to render the website. We can do this by setting a Bucket Policy under the Permissions tab.

我们还需要使该存储桶可公开访问,因为用户的浏览器需要访问该存储桶的文件才能呈现网站。 为此,我们可以在“权限”标签下设置存储桶策略。

{       "Version": "2012-10-17",       "Statement": [        {            "Sid": "PublicReadGetObject",            "Effect": "Allow",            "Principal": "*",            "Action": "s3:GetObject",            "Resource": "MY_BUCKET_ARN"        }    ]}

This is a simple policy that will only allow public read access of objects in the bucket. Now, if you head to the endpoint defined in the static hosting config of the bucket, you should see your website.

这是一个简单的策略,仅允许对存储桶中的对象进行公共读取访问。 现在,如果您转到存储桶的静态托管配置中定义的端点,则应该会看到您的网站。

Progress! But we can do better than that.

进展! 但是我们可以做得更好。

The second bucket (www.mywebsite.com) we will leave empty but configure to redirect to our first bucket using HTTP as the protocol (we’ll make it HTTPS later).

第二个存储桶(www.mywebsite.com)将保留为空,但配置为使用HTTP作为协议重定向到第一个存储桶(稍后将其设置为HTTPS)。

Your buckets are now ready to go!

您的水桶现在准备出发了!

使用Route53配置域 (Configure Domains with Route53)

So your website is up and running but only accessible via the bucket endpoint and not your custom domain. Let’s change that.

因此,您的网站已启动并正在运行,但只能通过存储桶端点访问,而不能通过自定义域访问。 让我们改变它。

Head to Route53. If you’ve registered your domain with the Amazon Registrar you should see that a hosted zone has been setup for you with two record sets. One for Name Server (NS) and one for SOA.

前往Route53 。 如果您已经在Amazon Registrar上注册了您的域,则应该看到已经为您设置了带有两个记录集的托管区域。 一个用于名称服务器(NS),另一个用于SOA。

All we need to do is to create two more record sets to point to the S3 bucket endpoints.

我们需要做的就是再创建两个记录集,以指向S3存储桶端点。

For each record set: — Type: A — IPv4 address — Alias: Yes — Alias Target: the S3 website endpoint that matches what you set for Name.

对于每个记录集:-类型:A-IPv4地址-别名:是-别名目标:与您为“名称”设置匹配的S3网站端点。

Now we can head to the custom url…and voilà!We’re almost there, but there’s one last thing we’re missing…

现在我们可以转到自定义网址了……瞧瞧!我们快到了,但是我们还缺少最后一件事……

Note: If your domain is registered with another domain registrar (not Amazon) you’ll need to follow some different steps to set this up. Usually you’ll need to add a CNAME record with a value of the main S3 buckets endpoint.

注意 :如果您的域名是在另一个域名注册机构(不是Amazon)注册的,则需要按照一些不同的步骤进行设置。 通常,您需要添加一个CNAME记录,并带有一个主S3存储桶端点的值。

Troubleshooting:If you deleted the hosted zone Amazon created when you first registered the domain (I’ve done this because hosted zones do incur some charges), you’ll need to create a new hosted zone from scratch.

故障排除 :如果您删除了首次注册域时由Amazon创建的托管区域(我这样做是因为托管区域确实会产生一些费用),则需要从头开始创建一个新的托管区域。

  1. Select “Create Hosted Zone” and set the domain name, for example “mywebsite.com”

    选择“创建托管区域”并设置域名,例如“ mywebsite.com”
  2. This will generate some new record sets for types NS and SOA.

    这将为NS和SOA类型生成一些新的记录集。
  3. Go into your registered domain and update the Name Servers values to those generated in the new NS record set.

    进入您的注册域,并将“名称服务器”值更新为在新NS记录集中生成的值。

申请证书 (Requesting a Certificate)

Awesome, the site is now hosted using the custom url! However we can only access it via HTTP protocol.We should always ensure our sites are secured using HTTPS protocol. This protects our site and users from malicious injection attacks and guarantees authenticity.

太棒了,该网站现在使用自定义网址托管! 但是,我们只能通过HTTP协议访问它。我们应始终确保使用HTTPS协议保护我们的网站的安全。 这样可以保护我们的网站和用户免受恶意注入攻击,并确保真实性。

Head to Certificate Manager in AWS Console and request a new public certificate (this is free). You’ll be prompted to enter the domain names you wish to secure.

前往AWS Console中的证书管理器并请求一个新的公共证书(这是免费的)。 系统将提示您输入要保护的域名。

Before the certificate can be issued, Amazon needs to be able to verify that you own the specified domains.

在颁发证书之前,Amazon需要能够验证您拥有指定的域。

You can choose from two verification methods: Email or DNS.

您可以从两种验证方法中选择:电子邮件或DNS。

Email is generally simpler, but you’ll need to ensure you can access the email used to register the domain. Alternatively, if you used Amazon Registrar and Route53, you can select the DNS method. This requires you to add some specific record sets to the hosted zone, but this is mostly automated for you so it’s quite simple.

电子邮件通常更简单,但是您需要确保可以访问用于注册域的电子邮件。 或者,如果您使用了Amazon Registrar和Route53,则可以选择DNS方法。 这要求您将一些特定的记录集添加到托管区域,但这对您来说大多是自动化的,因此非常简单。

It can take a few minutes for the certificate to be issued after validation. When its all done we can continue to the final step!

验证后可能需要花费几分钟才能颁发证书。 完成所有步骤后,我们可以继续执行最后一步!

配置CloudFront (Configuring CloudFront)

For the final step we are going to use CloudFront which allows us to use the new SSL certificate to serve the website with HTTPS. CloudFront also speeds up the distribution of web content by storing it at multiple edge locations and delivering from the closest edge location to a user.

对于最后一步,我们将使用CloudFront ,它允许我们使用新的SSL证书通过HTTPS为网站提供服务。 CloudFront还通过将Web内容存储在多个边缘位置并从最近的边缘位置传递给用户来加快Web内容的分发。

We need two new web distributions, one for each S3 bucket. Head to CloudFront in the AWS Console and create the first web distribution.There are lots of settings available to create a web distribution, but for the basics we only need to change five:

我们需要两个新的Web发行版 ,每个S3存储桶一个。 前往AWS控制台中的CloudFront并创建第一个Web分配。创建Web分配有很多可用设置,但对于基础知识,我们只需要更改以下五个设置:

  1. Origin Domain Name: Set this to the S3 website endpoint for one of the buckets. Important: This field will give you some auto-complete options with your S3 bucket names. However, using these can cause issues with redirecting to the bucket endpoint. So instead use the bucket endpoint directly.

    原始域名 :将其设置为其中一个存储桶的S3网站端点。 重要提示 :此字段将为您提供一些S3存储桶名称的自动填充选项。 但是,使用这些会导致重定向到存储桶端点的问题。 因此,请直接使用存储桶端点。

  2. Origin Id: This populated for you when you enter Origin Domain Name.

    原始ID :输入原始域名时为您填充。

  3. Viewer Protocol Policy: Set to “Redirect HTTP to HTTPS”.

    查看器协议策略 :设置为“将HTTP重定向到HTTPS”。

  4. Alternate Domain Names: This should match the name of the S3 bucket you’re pointing to. For example “mywebsite.com”.

    备用域名 :此名称应与您指向的S3存储桶的名称匹配。 例如“ mywebsite.com”。

  5. SSL Certificate: Select “Custom SSL Certificate” and select your new certificate from the dropdown.

    SSL证书 :选择“自定义SSL证书”,然后从下拉列表中选择新证书。

Do this again for the second S3 bucket.

对第二个S3存储桶再次执行此操作。

The distributions can take a while to spin up, so while we wait, let’s do the finishing steps.

这些发行版可能需要一段时间才能启动,因此在我们等待时,让我们完成最后的步骤。

Back in S3, go to your secondary bucket (www.mywebsite.com), in the Properties tab and under Static Website Hosting set the redirect protocol to HTTPS.

回到S3中 ,转到“辅助存储桶”(www.mywebsite.com),在“属性”选项卡中的“静态网站托管”下,将重定向协议设置为HTTPS。

Finally, head back to Route53. We need to update the custom A records we created to now target the CloudFront distributions rather than the S3 buckets. For each record, change the Alias Target and select the CloudFront distribution available in the dropdown.

最后,返回Route53 。 我们需要更新我们创建的自定义A记录,以现在定位到CloudFront分配而不是S3存储桶。 对于每条记录,更改Alias Target并在下拉列表中选择可用的CloudFront分配。

Note: Again, if you are using another DNS service you’ll need to go update the CNAME record from there to point to the CloudFront domain name.

注意:同样,如果您使用的是其他DNS服务,则需要从那里更新CNAME记录,以指向CloudFront域名。

And there you have it! Your beautiful website is now available at the custom domain and served with HTTPS!

在那里,您拥有了! 您美丽的网站现在可以在自定义域中使用,并通过HTTPS服务!

Thanks for reading! I hope this guide was useful and enjoyable, I’d love to know if you found it helpful.

谢谢阅读! 希望本指南对您有所帮助并且愉快,我很想知道您是否对本指南有所帮助。

翻译自: https://www.freecodecamp.org/news/simple-site-hosting-with-amazon-s3-and-https-5e78017f482a/

亚马逊 各国站点 链接

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

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

相关文章

leetcode 387. 字符串中的第一个唯一字符(hash)

给定一个字符串,找到它的第一个不重复的字符,并返回它的索引。如果不存在,则返回 -1。 示例: s “leetcode” 返回 0 s “loveleetcode” 返回 2 class Solution { public int firstUniqChar(String s) { int[][] tempnew i…

marlin 三角洲_三角洲湖泊和数据湖泊-入门

marlin 三角洲Data lakes are becoming adopted in more and more companies seeking for efficient storage of their assets. The theory behind it is quite simple, in contrast to the industry standard data warehouse. To conclude this this post explains the logica…

tomcat中设置Java 客户端程序的http(https)访问代理

1、假定http/https代理服务器为 127.0.0.1 端口为8118 2、在tomcat/bin/catalina.sh脚本文件中设置JAVA_OPTS,如下图: 保存后重启tomcat就能生效。转载于:https://www.cnblogs.com/zhangmingcheng/p/11211776.html

java界面中显示图片_java中怎样在界面中显示图片?

方法一:JLabel helloLabel new JLabel("New label");helloLabel.setIcon(new ImageIcon("E:\\javaSE\u4EE3\u7801\\TimeManager\\asset\\hello.gif"));helloLabel.setBackground(Color.BLACK);helloLabel.setBounds(0, 0, 105, 50);contentPan…

one-of-k 编码算法_我们如何教K-12学生如何编码

one-of-k 编码算法by Christopher George克里斯托弗乔治(Christopher George) 我们如何教K-12学生如何编码 (How we’re teaching K-12 students how to code) Hello World! (Sorry, I couldn’t resist.) My name is Christopher George and I am currently a Junior at Carn…

knime简介_KNIME简介

knime简介Data Science is abounding. It considers different realms of the data world including its preparation, cleaning, modeling, and whatnot. To be precise, it is massive in terms of the span it covers and the opportunities it offers. Needless to say, th…

hadoop2.x HDFS快照介绍

说明:由于近期正好在研究hadoop的快照机制。看官网上的文档讲的非常仔细。就顺手翻译了。也没有去深究一些名词的标准译法,所以可能有些翻译和使用方法不是非常正确,莫要介意~~ 原文地址:(Apache hadoop的官方文档&…

MQTT服务器搭建--Mosquitto用户名密码配置

前言: 基于Mosquitto服务器已经搭建成功,大部分都是采用默认的是允许匿名用户登录模式,正式上线的系统需要进行用户认证。 1.用户参数说明 Mosquitto服务器的配置文件为/etc/mosquitto/mosquitto.conf,关于用户认证的方式和读取的…

java number string_java基础系列(一):Number,Character和String类及操作

这篇文章总结了Java中最基础的类以及常用的方法,主要有:Number,Character,String。1、Number类在实际开发的过程中,常常会用到需要使用对象而不是内置的数据类型的情形。所以,java语言为每个内置数据类型都…

谁参加了JavaScript 2018状况调查?

by Sacha Greif由Sacha Greif 谁参加了JavaScript 2018状况调查? (Who Took the State of JavaScript 2018 Survey?) 我们如何努力使调查更具代表性 (How we’re working to make the survey more representative) I was recently listening to a podcast episode…

机器学习 建立模型_建立生产的机器学习系统

机器学习 建立模型When businesses plan to start incorporating machine learning to enhance their solutions, they more often than not think that it is mostly about algorithms and analytics. Most of the blogs/training on the matter also only talk about taking …

CDH使用秘籍(一):Cloudera Manager和Managed Service的数据库

背景从业务发展需求,大数据平台须要使用spark作为机器学习、数据挖掘、实时计算等工作,所以决定使用Cloudera Manager5.2.0版本号和CDH5。曾经搭建过Cloudera Manager4.8.2和CDH4,在搭建Cloudera Manager5.2.0版本号的时候,发现对…

leetcode 455. 分发饼干(贪心算法)

假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。 对每个孩子 i,都有一个胃口值 g[i],这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j,都有一个尺寸 s[j]…

压缩/批量压缩/合并js文件

写在前面 如果文件少的话,直接去网站转化一下就行。 http://tool.oschina.net/jscompress?type3 1.压缩单个js文件 cnpm install uglify-js -g 安装 1>压缩单个js文件打开cmd,目录引到当前文件夹,cduglifyjs inet.js -o inet-min.js 或者 uglifyjs i…

angular依赖注入_Angular依赖注入简介

angular依赖注入by Neeraj Dana由Neeraj Dana In this article, we will see how the dependency injection of Angular works internally. Suppose we have a component named appcomponent which has a basic and simple structure as follows:在本文中,我们将看…

leetcode 85. 最大矩形(dp)

给定一个仅包含 0 和 1 、大小为 rows x cols 的二维二进制矩阵,找出只包含 1 的最大矩形,并返回其面积。 示例 1: 输入:matrix [[“1”,“0”,“1”,“0”,“0”],[“1”,“0”,“1”,“1”,“1”],[“1”,“1”,“1”,“1”,“…

如何查看系统版本

1. winR,输入cmd,确定,打开命令窗口,输入msinfo32,注意要在英文状态下输入,回车。然后在弹出的窗口中就可以看到系统的具体版本号了。 2.winR,输入cmd,确定,打开命令窗口,输入ver&am…

java activemq jmx_通过JMX 获取Activemq 队列信息

首先在 activemq.xml 中新增以下属性在broker 节点新增属性 useJmx"true"在managementContext 节点配置断开与访问服务iP配置成功后启动下面来看测试代码/*** Title: ActivemqTest.java* Package activemq* Description: TODO(用一句话描述该文件做什么)* author LYL…

风能matlab仿真_发现潜力:使用计算机视觉对可再生风能发电场的主要区域进行分类(第1部分)

风能matlab仿真Github Repo: https://github.com/codeamt/WindFarmSpotterGithub回购: https : //github.com/codeamt/WindFarmSpotter This is a series:这是一个系列: Part 1: A Brief Introduction on Leveraging Edge Devices and Embedded AI to …

【Leetcode_easy】821. Shortest Distance to a Character

problem 821. Shortest Distance to a Character 参考 1. Leetcode_easy_821. Shortest Distance to a Character; 完转载于:https://www.cnblogs.com/happyamyhope/p/11214805.html