亞馬遜 各國站點 鏈接_使用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.pswp.cn/news/392444.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/392444.shtml
英文地址,請注明出處:http://en.pswp.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