<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mugunthanselvaraj</title>
    <description>The latest articles on DEV Community by mugunthanselvaraj (@mugunthanselvaraj).</description>
    <link>https://dev.to/mugunthanselvaraj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1007375%2F7be0d44c-2e7b-4606-bf3d-a3e93346b874.png</url>
      <title>DEV Community: mugunthanselvaraj</title>
      <link>https://dev.to/mugunthanselvaraj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mugunthanselvaraj"/>
    <language>en</language>
    <item>
      <title>Understanding CORS, CSRF attacks and enabling valid CORS</title>
      <dc:creator>mugunthanselvaraj</dc:creator>
      <pubDate>Sun, 21 Jan 2024 13:33:07 +0000</pubDate>
      <link>https://dev.to/mugunthanselvaraj/understanding-cors-csrf-attacks-and-enabling-valid-cors-3ko6</link>
      <guid>https://dev.to/mugunthanselvaraj/understanding-cors-csrf-attacks-and-enabling-valid-cors-3ko6</guid>
      <description>&lt;p&gt;In this post, using some basic questions will try to explain what CORS is, CSRF attacks, how modern browsers protect from CSRF attacks and how to enable valid CORS when needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is CORS?&lt;/strong&gt;&lt;br&gt;
CORS stands for acronym - Cross Origin Resource Sharing&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When you should worry about using CORS?&lt;/strong&gt;&lt;br&gt;
Only when you use browsers for API access&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When do you see the CORS error?&lt;/strong&gt;&lt;br&gt;
While using browsers, you may need to incorporate content by sending a request to another domain and you would have landed on a CORS error.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do browsers need a CORS policy?&lt;/strong&gt;&lt;br&gt;
It is a security feature to detect and avoid data sharing and access from different origins.&lt;br&gt;
This is needed to tackle CSRF - Cross-Site request forgery attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is same-origin policy?&lt;/strong&gt;&lt;br&gt;
A Security feature to detect and avoid data sharing and access from different origins.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How does CORS secure a website by avoiding CSRF attacks?&lt;/strong&gt;&lt;br&gt;
Faking websites can mock the request/response of original websites and perform GET/PUT/POST/DELETE operations as shown below:&lt;br&gt;
Browser:&lt;br&gt;
Fake origin request ---------request--------&amp;gt; Bank origin&lt;br&gt;
Fake origin blocked to execute  &amp;lt;--------response--------- Bank origin response&lt;br&gt;
Since the browser will be able to differentiate and identify from the response that it is from the bank, it will block it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Which are all the components used for CORS in a URL?&lt;/strong&gt;&lt;br&gt;
    1. protocol - HTTP or HTTPS should match&lt;br&gt;
    2. The domain name should match - e.g. example.com&lt;br&gt;
    3. port - 80 or 443 should match&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Valid requests&lt;/u&gt;&lt;br&gt;
    &lt;code&gt;http://example.com&lt;/code&gt;   &amp;amp;&amp;amp; &lt;code&gt;http://example.com/api/rooms&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Invalid requests&lt;/u&gt;&lt;br&gt;
    &lt;code&gt;http://example.com&lt;/code&gt;   &amp;amp;&amp;amp;  &lt;code&gt;https://api.example.com/rooms&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When do you need to enable CORS?&lt;/strong&gt;&lt;br&gt;
CORS is important when you use cross-domain browser clients. There is a requirement that you need to share data between your own websites (having different origins say abc.com and xyz.com) through API calls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How you can enable it?&lt;/strong&gt;&lt;br&gt;
CORS allows the browser to explicitly whitelist certain origins and relax the browser's same-origin policy&lt;/p&gt;

&lt;p&gt;The server will be configured with CORS it will return some extra headers with each response&lt;br&gt;
This response whitelist &lt;br&gt;
    * Certain origins&lt;br&gt;
    * HTTP methods&lt;br&gt;
    * Headers&lt;br&gt;
    * Other elements of the request&lt;/p&gt;

&lt;p&gt;The browser looks at the response and makes the decision.&lt;br&gt;
CORS requires support on both the server and the browser to work.&lt;br&gt;
The server controls the server's response that whitelists certain origins, but the final decision to allow the response is made by the browser.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do you do to enable CORS on the origin server?&lt;/strong&gt;&lt;br&gt;
    * Determine which origins to whitelist&lt;br&gt;
    * Add CORS middleware to the server&lt;/p&gt;

&lt;p&gt;CORS Headers - The following are the related headers for CORS&lt;br&gt;
    &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Access-Control-Allow-Credentials&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Access-Control-Allow-Headers&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Access-Control-Allow-Methods&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Access-Control-Expose-Headers&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Access-Control-Max-Age&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Access-Control-Request-Headers&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Access-Control-Request-Method&lt;/code&gt;&lt;br&gt;
    &lt;code&gt;Origin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Among the above the important header is &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt;&lt;br&gt;
This is used to allow access to which origin resources.&lt;br&gt;
This header is used/enforced by the browser to make a decision on whether this response content can be allowed.&lt;br&gt;
If this response's header contains the current origin (browser url), it is allowed to be rendered. Else not.&lt;br&gt;
Browser:&lt;br&gt;
Origin A (current URL) --------------&amp;gt; Orgin B(another URL)&lt;br&gt;
Origin A (current URL) &amp;lt;-------------- Origin B response&lt;br&gt;
If Origin's B response contains 'Access-Control-Allow-Origin' to allow Origin A, then the browser renders the response. Else blocks it.&lt;/p&gt;

&lt;p&gt;Reference:&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS"&gt;https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enable CORS in ruby on rails:&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/17858178/allow-anything-through-cors-policy"&gt;https://stackoverflow.com/questions/17858178/allow-anything-through-cors-policy&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enable CORS in a Java application:&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/44905898/how-to-enable-cors-on-server-side-code-in-java"&gt;https://stackoverflow.com/questions/44905898/how-to-enable-cors-on-server-side-code-in-java&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Enable CORS in a C# application:&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/31942037/how-to-enable-cors-in-asp-net-core"&gt;https://stackoverflow.com/questions/31942037/how-to-enable-cors-in-asp-net-core&lt;/a&gt;&lt;br&gt;
&lt;a href="https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-8.0"&gt;https://learn.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-8.0&lt;/a&gt;&lt;/p&gt;

</description>
      <category>websecurity</category>
      <category>cors</category>
      <category>csrf</category>
      <category>browser</category>
    </item>
    <item>
      <title>How to create a static website locally, push it to github, then to AWS S3 using AWS codepipeline and publish it automatically.</title>
      <dc:creator>mugunthanselvaraj</dc:creator>
      <pubDate>Thu, 13 Apr 2023 21:59:59 +0000</pubDate>
      <link>https://dev.to/mugunthanselvaraj/how-to-create-a-static-website-locally-push-it-to-github-then-to-aws-s3-using-aws-codepipeline-and-publish-it-automatically-jkg</link>
      <guid>https://dev.to/mugunthanselvaraj/how-to-create-a-static-website-locally-push-it-to-github-then-to-aws-s3-using-aws-codepipeline-and-publish-it-automatically-jkg</guid>
      <description>&lt;p&gt;This post shows how you can create a local static website, push to github, then to AWS S3 using AWS code pipeline automatically for every commit to the remote github repository and publish it as a website automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-1 Create your local project
&lt;/h2&gt;

&lt;p&gt;Create your local files for the website using your favorite IDE (like VS code). In my case I created the files in the following location C:\Users\MugunthanSelvaraj\Desktop\MyNewWebSite&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie1ijfn86x2c77jx5caj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fie1ijfn86x2c77jx5caj.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Sample html, css and javascript files are given here:&lt;br&gt;
index.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
        &amp;lt;title&amp;gt;My Website using S3&amp;lt;/title&amp;gt;
        &amp;lt;link rel="stylesheet" href="index.css"/&amp;gt;
        &amp;lt;link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous"/&amp;gt;
        &amp;lt;script src="https://code.jquery.com/jquery-3.6.3.min.js"&amp;gt;&amp;lt;/script&amp;gt;
        &amp;lt;script src="index.js"&amp;gt;&amp;lt;/script&amp;gt;
        &amp;lt;script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js" integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN" crossorigin="anonymous"&amp;gt;&amp;lt;/script&amp;gt;
    &amp;lt;/head&amp;gt;
    &amp;lt;body&amp;gt;
        &amp;lt;main role="main" class="container"&amp;gt;
            &amp;lt;h1 class="mt-5"&amp;gt;Welcome Demo page&amp;lt;/h1&amp;gt;
            &amp;lt;p class="lead"&amp;gt;This is my demo page for S3 web hosting.&amp;lt;/p&amp;gt;
        &amp;lt;/main&amp;gt;
        &amp;lt;div id="animation"&amp;gt;hover over me&amp;lt;/div&amp;gt;
    &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;index.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$(document).ready(function(){
    $("#animation").hover(function(){
        $(this).animate({height: "200px"});
    });

    $("#animation").mouseout(function(){
        $(this).animate({height: "100px"});
    });
})

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;index.css&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;html, body{
    height: 100%;
}
#animation{
    width: 100px;
    height: 100px;
    background-color: red;
    position: relative;
    animation-name: box;
    animation-duration: 5s;
    animation-timing-function: linear;
    animation-delay: 2s;
    animation-iteration-count: infinite;
    animation-direction: alternate;
  }


@keyframes box {
    0%   {background-color:red; left:0px; top:0px;}
    25%  {background-color:yellow; left:200px; top:0px;}
    50%  {background-color:blue; left:200px; top:200px;}
    75%  {background-color:green; left:0px; top:200px;}
    100% {background-color:red; left:0px; top:0px;}
  }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step-2 Setup Git repository and push it to remote
&lt;/h2&gt;

&lt;p&gt;To do first time git setup check out &lt;a href="https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup" rel="noopener noreferrer"&gt;this&lt;/a&gt;&lt;br&gt;
Use the following git commands to create the repository locally.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Initialize git repository in the project folder. In my case &lt;code&gt;C:\Users\MugunthanSelvaraj\Desktop\MyNewWebSite&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git init&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Add all files to the repository&lt;br&gt;
&lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Commit the files to the local repository&lt;br&gt;
&lt;code&gt;git commit -m “my website using AWS S3”&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Before proceeding further, you need to have your remote git repository&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create and/or login to your github account&lt;/li&gt;
&lt;li&gt;Create a new repository using the ‘new’ button&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsu6rxxq53rmmz9ug2lo5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsu6rxxq53rmmz9ug2lo5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Give suitable name and description&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwoxgb5csnz8kjed94tcj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwoxgb5csnz8kjed94tcj.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can add readme.md file if you need. Click ‘create repository’&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1qozmq0w3gwc3p1anu45.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1qozmq0w3gwc3p1anu45.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once repository is created in your github account, it will suggest you how to push your local code to remote git repository.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Add remote origin&lt;br&gt;
&lt;code&gt;git remote add origin git@github.com:your_github_account/mynewwebsite.git&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create and name main branch&lt;br&gt;
&lt;code&gt;git branch -M main&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Push the code to github&lt;br&gt;
&lt;code&gt;git push -u origin main&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After the above commands are successful, you should be able to see your local files successfully pushed to remote git repository&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgel83kgm4c8zrpiarhti.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgel83kgm4c8zrpiarhti.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-3 Create AWS S3 bucket for code push
&lt;/h2&gt;

&lt;p&gt;In your AWS S3, create a new S3 bucket where you want to push the code from github to and then you will publish it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tbrgoo2t6ss0g1s1nli.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9tbrgoo2t6ss0g1s1nli.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Note that the bucket name should be unique across all AWS S3. So have some other name other than shown here.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yt3ogucmtoixymtc8pa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0yt3ogucmtoixymtc8pa.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Uncheck ‘block all public access’&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22ma5r6cbbzdgbi4ijnf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22ma5r6cbbzdgbi4ijnf.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Acknowledge and create the bucket.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkamkuebucngmhdadfa53.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkamkuebucngmhdadfa53.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-4 Create AWS code pipeline to push the code automatically to your S3 bucket
&lt;/h2&gt;

&lt;p&gt;Goto AWS code pipeline&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o57lwbizp8emaojh3ey.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9o57lwbizp8emaojh3ey.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create new pipeline by giving a name as shown below and press next&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2fqbalhpsxt44b5qsiy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi2fqbalhpsxt44b5qsiy.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under source stage, select github 1 or 2 depending on which you are using&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypp2bg2y5m45azuwzv8v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fypp2bg2y5m45azuwzv8v.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click connect to Github. This would prompt github login and show you dialog&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwzjjzprexcxxkemq2ucu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwzjjzprexcxxkemq2ucu.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Give the connection name as same as your remote github repository name and select connect.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieqpqwqndbxw0o32idgk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fieqpqwqndbxw0o32idgk.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbnz39xv3xmfsch7ldhzs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbnz39xv3xmfsch7ldhzs.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Provide the repository name and branch name of your github repository&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc24g1zt8jt48tijv6l5h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc24g1zt8jt48tijv6l5h.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Skip the build stage as we are deploying a static website&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb43mln6w6g1de82tmtnk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb43mln6w6g1de82tmtnk.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26g8ae7cnomsta4r6255.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F26g8ae7cnomsta4r6255.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under deploy stage, select the deploy provider as ‘Amazon S3’, bucket with the same bucket name which you created&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9hp844c7ekyhjvl884h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj9hp844c7ekyhjvl884h.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Make sure you check the ‘Extract file before deploy’&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj83j6e6ptomk0ktbtnp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbj83j6e6ptomk0ktbtnp.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Review and create the pipeline.&lt;br&gt;
Your pipeline should be successfully created and deployed after few minutes&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa14ywedxnhyv3rl4zhg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa14ywedxnhyv3rl4zhg7.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8j7eyku5af6ffrf5txf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw8j7eyku5af6ffrf5txf.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Sometimes the above action would fail with error ‘insufficient permission’. Ignore and retry, it should succeed after some time.&lt;br&gt;
Now your S3 bucket would have all the files which you have in your github repository.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkrot5ros0i8f4rz0hn5q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkrot5ros0i8f4rz0hn5q.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-5 Making your S3 bucket as a publicly available static website
&lt;/h2&gt;

&lt;p&gt;Goto your S3 bucket and properties tab:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzc36zwbw3kv4m938jtg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvzc36zwbw3kv4m938jtg.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Go below to ‘Static website hosting’ section and click ‘Edit’ button&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feaoyalcpgtumuiqcbqh5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feaoyalcpgtumuiqcbqh5.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Enable static website hosting and specify the ‘index document’ with our ‘index.html’ value.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgu5kabm7vu0gqxfs74ec.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgu5kabm7vu0gqxfs74ec.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Save the changes.&lt;br&gt;
Now goto the ‘permission’ section of the bucket&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidg0v5zhmcx7fe09bttd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fidg0v5zhmcx7fe09bttd.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Edit ‘block public access’ and uncheck ‘block all public access’&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0367h2mltmdhu4f72vz2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0367h2mltmdhu4f72vz2.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Save and confirm the changes.&lt;br&gt;
Edit the Bucket policy&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz48m57nm12asbcli8iq6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz48m57nm12asbcli8iq6.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Use the policy generator&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsjz308zutt3s1n95hcu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxsjz308zutt3s1n95hcu.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Copy the bucket ARN above and specify the following values as shown below:&lt;br&gt;
Type of policy: S3 bucket policy&lt;br&gt;
Effect: Allow&lt;br&gt;
Principal: * (Allow for all)&lt;br&gt;
Under Actions: select GetObject&lt;br&gt;
For ARN paste the one copied from the above which the Amazon Resource Name for the bucket. Make sure it ends with &lt;code&gt;/*&lt;/code&gt; (Else this would give error for the policy)&lt;br&gt;
Add statement and generate the policy.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm35z6fzvm7y4nbeb9f4r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm35z6fzvm7y4nbeb9f4r.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4krbvr3ekbxsh2br9cct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4krbvr3ekbxsh2br9cct.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
A pop up would be shown with a generated JSON policy&lt;br&gt;
Copy it and paste it in the bucket policy section for the bucket&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7u9kmsfc6aoe98had00j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7u9kmsfc6aoe98had00j.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Save the changes.&lt;br&gt;
Now got the ‘properties’ section of the bucket. Under Static website hosting, copy the bucket website endpoint.&lt;br&gt;
Paste it in a browser and test it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2n3oukivopxera3cgbfo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2n3oukivopxera3cgbfo.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your website should be publicly available now.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvji8zr109w33oalms06w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvji8zr109w33oalms06w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-6 Checking the codepipeline
&lt;/h2&gt;

&lt;p&gt;Now we have our S3 bucket in sync with our Git repository. Let us check this from our local.&lt;br&gt;
Open your local file. Add some changes and modify index.html.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9pizdcv74c8a0knmx9mo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9pizdcv74c8a0knmx9mo.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Add the changes to your local repository&lt;br&gt;
&lt;code&gt;git add .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Commit this change&lt;br&gt;
&lt;code&gt;git commit -m “Adding new changes”&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Push it to the remote repository&lt;br&gt;
&lt;code&gt;git push&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Observe your AWS CodePipeline. It should have started now to pick up your changes from git remote repository and sync it to S3 bucket&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3sp05zdfafai6g0dj49.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj3sp05zdfafai6g0dj49.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once this is success, refresh your page browser. You will observe that the local changes are automatically pushed to your static website.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc9ic6eqjzujxajd9o6d2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc9ic6eqjzujxajd9o6d2.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>staticwebapps</category>
      <category>awss3</category>
      <category>github</category>
      <category>awscodepipeline</category>
    </item>
    <item>
      <title>How to create and launch your own secured (HTTPS) web site using AWS EC2, Ubuntu, Nginx, AWS Route 53 and LetsEncrypt?</title>
      <dc:creator>mugunthanselvaraj</dc:creator>
      <pubDate>Thu, 06 Apr 2023 15:15:47 +0000</pubDate>
      <link>https://dev.to/mugunthanselvaraj/how-to-create-and-launch-your-own-secured-https-web-site-with-using-aws-ec2-ubuntu-nginx-aws-route-53-letsencrypt-4c72</link>
      <guid>https://dev.to/mugunthanselvaraj/how-to-create-and-launch-your-own-secured-https-web-site-with-using-aws-ec2-ubuntu-nginx-aws-route-53-letsencrypt-4c72</guid>
      <description>&lt;p&gt;This post explains how you can register your own domain using AWS Route 53, then hosting your own website using this domain over nginx server on an Ubuntu server and securing it (HTTPS) with LetsEncrypt&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-1 Get domain name in AWS Route 53
&lt;/h2&gt;

&lt;p&gt;You need your public domain name like google.com or amazon.com in order to make the public users access it. Following steps shows how you can purchase a public domain name in AWS Route 53&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In AWS console, search Route 53&lt;/li&gt;
&lt;li&gt;Select ‘Register domain’. You can select your domain name with extension based on the availability and your price selection.
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2pVaTy01--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yeoc58hcty52zvfdplv9.png" alt="Image description" width="800" height="333"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vvEvN-JW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8oge95evcxqbd2e9r8p5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vvEvN-JW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8oge95evcxqbd2e9r8p5.png" alt="Image description" width="800" height="185"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eXvIVFU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrh639kvdrwdgezo6xds.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eXvIVFU9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vrh639kvdrwdgezo6xds.png" alt="Image description" width="800" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add to cart and add registrant contact details. &lt;/li&gt;
&lt;li&gt;Check your contact details. Accept Terms &amp;amp; conditions and complete the order.
In some cases you may need to complete the payment through AWS billing so that your domain is enabled and available.
Once your have your domain name registered with AWS Route 53, you can continue to use this domain for yourself.
You should receive an email to confirm your domain as shown: (this would take some time say 30 min)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--1ViQbnVP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5oujlsjcyp9a0zrdpknr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--1ViQbnVP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5oujlsjcyp9a0zrdpknr.png" alt="Image description" width="686" height="311"&gt;&lt;/a&gt;&lt;br&gt;
Confirm this email to further setup your server for website.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step-2 Host an EC2 instance in AWS with Ubuntu
&lt;/h2&gt;

&lt;p&gt;Goto AWS EC2.&lt;br&gt;
Click Launch instances.&lt;br&gt;
Give a suitable name for your server&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NuNKFPeN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9a6i037jciy2px0miba.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NuNKFPeN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n9a6i037jciy2px0miba.png" alt="Image description" width="611" height="232"&gt;&lt;/a&gt;&lt;br&gt;
Select ‘Ubuntu’ as application OS image&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vBB6MRfa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lirnfjsdweo53dcxgtk9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vBB6MRfa--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lirnfjsdweo53dcxgtk9.png" alt="Image description" width="613" height="399"&gt;&lt;/a&gt;&lt;br&gt;
Choose instance type according to your purpose. Here I am choosing &lt;code&gt;t2.micro&lt;/code&gt; &lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vz-cwqxb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf84quv75vcomsnzb49k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vz-cwqxb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf84quv75vcomsnzb49k.png" alt="Image description" width="800" height="253"&gt;&lt;/a&gt;&lt;br&gt;
Select ‘Create Key pair’ option and create a new keypair to generate a new permission file (*.pem)&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sSSrmtfH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5aspbt3bsff5emyapx9c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sSSrmtfH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5aspbt3bsff5emyapx9c.png" alt="Image description" width="761" height="772"&gt;&lt;/a&gt;&lt;br&gt;
Save this file and it will be available only during creation. Make sure you store it carefully so you don’t lose it.&lt;br&gt;
Edit network settings and provide appropriate values&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sxbZYfce--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5hj2hp4rce4hi1vz1io.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sxbZYfce--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f5hj2hp4rce4hi1vz1io.png" alt="Image description" width="617" height="461"&gt;&lt;/a&gt;&lt;br&gt;
Under inbound security group rules, add the types HTTP and HTTPS&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DILu-VRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wwn8mefxkby2d402mqg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DILu-VRJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9wwn8mefxkby2d402mqg.png" alt="Image description" width="621" height="433"&gt;&lt;/a&gt;&lt;br&gt;
Configure storage based on your purpose. Here I am leaving it as default 8GB.&lt;br&gt;
Review all and select ‘Launch instance’&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DcRn8-Rr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u1z5uojw0tk4z6o83mc2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DcRn8-Rr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/u1z5uojw0tk4z6o83mc2.png" alt="Image description" width="338" height="494"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step-3 Attach an elastic IP
&lt;/h2&gt;

&lt;p&gt;Once the instance is successfully launched, go to Network&amp;amp;Security -&amp;gt; Elastic IPs&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JH1RPwG4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdkoatdqq79i7xq4syf1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JH1RPwG4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pdkoatdqq79i7xq4syf1.png" alt="Image description" width="736" height="483"&gt;&lt;/a&gt;&lt;br&gt;
Select ‘Allocate Elastic IP address’&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HVmjofnr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swtoippy87x11mdxzo8e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HVmjofnr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swtoippy87x11mdxzo8e.png" alt="Image description" width="800" height="237"&gt;&lt;/a&gt;&lt;br&gt;
Add new tag ‘Name’ and provide a reasonable name.&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ld8mQdBC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trculwfbp4nbf5wcmcjk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ld8mQdBC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trculwfbp4nbf5wcmcjk.png" alt="Image description" width="640" height="628"&gt;&lt;/a&gt;&lt;br&gt;
Select ‘Allocate’ button.&lt;br&gt;
Once the elastic ip data is created, use ‘associate this elastic ip address’ button to assign IP to your above created ubuntu server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KPzXjWyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gh1zpp5snth8wcql2i8h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KPzXjWyH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gh1zpp5snth8wcql2i8h.png" alt="Image description" width="800" height="300"&gt;&lt;/a&gt;&lt;br&gt;
Select your server and associate this IP with it&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ntaCJGh8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfhd2zas6xfz9zsb9pk7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ntaCJGh8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pfhd2zas6xfz9zsb9pk7.png" alt="Image description" width="456" height="412"&gt;&lt;/a&gt;&lt;br&gt;
Now you would observe this elastic IP is same as your EC2 instance IP address&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OmnMkNdE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xoftadvf0nf7dk0akj62.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OmnMkNdE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xoftadvf0nf7dk0akj62.png" alt="Image description" width="800" height="266"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8alUp3rY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0060doq8k3lqzporhxy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8alUp3rY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0060doq8k3lqzporhxy.png" alt="Image description" width="800" height="345"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step-4 Install and Nginx
&lt;/h2&gt;

&lt;p&gt;You can now connect to your EC2 instance and setup the website&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use ssh command to connect to your EC2 instance (on windows try using &lt;a href="https://www.cygwin.com/"&gt;Cygwin&lt;/a&gt; or &lt;a href="https://git-scm.com/download/win"&gt;Git Bash&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;To start with make sure you set your pem file downloaded with read-only permission
&lt;code&gt;chmod 400 &amp;lt;path to your pem file&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Connect to your server instance using the ssh command, server name and pem file
&lt;code&gt;ssh -i &amp;lt;path to your pem file&amp;gt; ubuntu@your_server_name&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Input ‘yes’ to add your finger print&lt;/li&gt;
&lt;li&gt;Switch root user (as installations will be done as an root user)
&lt;code&gt;sudo su -&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Update ubuntu 
&lt;code&gt;apt update&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Install nginx
&lt;code&gt;apt install -y nginx&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;This would install nginx and would have started it in background. You can verify the nginx status by 
&lt;code&gt;systemctl status nginx&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RPsOmq8_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdda236j1c295hin4o3y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RPsOmq8_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jdda236j1c295hin4o3y.png" alt="Image description" width="800" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Following are the key locations/files where the configurations and files handled by nginx are located:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;view the logs&lt;br&gt;
&lt;code&gt;/var/log/nginx&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;view the configurations &lt;br&gt;
&lt;code&gt;/etc/nginx/nginx.conf&lt;/code&gt;&lt;br&gt;
&lt;code&gt;/etc/nginx/sites-enabled/default&lt;/code&gt;&lt;br&gt;
&lt;code&gt;/etc/nginx/conf.d/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;website location&lt;br&gt;
&lt;code&gt;/var/www/html&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Test the nginx configuration without loading using the following command
&lt;code&gt;nginx -t&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hU0PRjrY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ko5j9n7ar6inm3trdm26.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hU0PRjrY--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ko5j9n7ar6inm3trdm26.png" alt="Image description" width="800" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Place your website static files in this location &lt;code&gt;/var/www/html&lt;/code&gt;. If the location does not exist, create the same. By default nginx creates this location and place a default index file 
&lt;code&gt;/var/www/html/index.nginx-debian.html&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;You can verify this by going to a browser and typing the following: (replace the IP address with your EC2 instance public IP address)
&lt;code&gt;http://your_public_ip_address&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fcUj2krf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5a5na5xpzt76mlz252u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fcUj2krf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v5a5na5xpzt76mlz252u.png" alt="Image description" width="800" height="286"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now we can continue to have our own web page developed and placed in this location: &lt;code&gt;/var/www/html/&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Contents of the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;My Own page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;This is my own web page&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Placed in this location on a file &lt;code&gt;/var/www/html/index.html&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In order to point nginx to this new index page, open the default configuration of nginx
&lt;code&gt;vim /etc/nginx/sites-enabled/default&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Locate the directive &lt;code&gt;index&lt;/code&gt; and modify such that our new file is mentioned there, and other file names are removed
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y6eJCs5R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vnaqvw5apo8lczy41btl.png" alt="Image description" width="619" height="282"&gt;
&lt;/li&gt;
&lt;li&gt;Specify the server_name directive with your domain name created above
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--b27MnmQ6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bhkyrs416e6gp7yq4u39.png" alt="Image description" width="700" height="236"&gt;
&lt;/li&gt;
&lt;li&gt;Test and reload the nginx&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;nginx -t&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;systemctl reload nginx&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now if you refresh the URL above in a browser, you should see your own page&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CiyIfjB1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19cwy3wyv3bv1zhrgm8x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CiyIfjB1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19cwy3wyv3bv1zhrgm8x.png" alt="Image description" width="453" height="195"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-5 Test your website with HTTP
&lt;/h2&gt;

&lt;p&gt;Now instead of using the IP address we will map the domain name what we created to this web site&lt;br&gt;
Once you have the domain successfully registered,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--FmDmoYKd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rbelxa18pu3up8fr5uh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--FmDmoYKd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8rbelxa18pu3up8fr5uh.png" alt="Image description" width="800" height="163"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to ‘Hosted zone’ and select your hosted zone name
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bABNQUus--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nx5trw14zv7k51aje38v.png" alt="Image description" width="800" height="206"&gt;
&lt;/li&gt;
&lt;li&gt;Create a new record by specifying your instance public IP address
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hJwZfR5e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5smhxb0tjpb21gmibdnr.png" alt="Image description" width="706" height="338"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4ttEduNN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0s3tw1msmr2gdtbkxdgz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4ttEduNN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0s3tw1msmr2gdtbkxdgz.png" alt="Image description" width="671" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After the record is created, you can view the status. Make sure that this is in INSYNC
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kGTjFyu3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yr906uls2wvfep9z32uu.png" alt="Image description" width="683" height="234"&gt;
&lt;/li&gt;
&lt;li&gt;You can verify this domain mapping in Ubuntu using the ‘dig’ command&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zQuCY5Ke--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5opvxoygh8lh955aee3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zQuCY5Ke--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o5opvxoygh8lh955aee3.png" alt="Image description" width="735" height="448"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The same can be verified in windows using ‘nslookup’
&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--n4cynUjE--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/miqw8svq134yogg4qx1q.png" alt="Image description" width="731" height="227"&gt;
&lt;/li&gt;
&lt;li&gt;Once the above is in place, you now access your website using the domain name what you created
&lt;a href="http://mugunthanselvaraj.link"&gt;http://mugunthanselvaraj.link&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--spcnc_Bz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6hmlnmigck5wz8iqrfl.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--spcnc_Bz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m6hmlnmigck5wz8iqrfl.png" alt="Image description" width="800" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-6 Securing the website with https using letsencrypt
&lt;/h2&gt;

&lt;p&gt;The current website what we have is http based and is not secured. In order to secure it with SSL/TLS encryption so that it can be accessed over https protocol, we can use letsencrypt to add a SSL certificate to our nginx server.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In order to use certbot (letsencrypt) we need to have snap installed (package manager) in ubuntu. By default this is available. You can verify this by
&lt;code&gt;snap version&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QPr3FeI5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sh7bql54mod3nuq9l9dm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QPr3FeI5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sh7bql54mod3nuq9l9dm.png" alt="Image description" width="607" height="210"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Verify for latest version
&lt;code&gt;apt policy snapd&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3BC561u6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7yg6hvwysiwnazyi9a26.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3BC561u6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7yg6hvwysiwnazyi9a26.png" alt="Image description" width="800" height="212"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download and update it by using the following commands&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;snap install core;  snap refresh core&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remove if you have already have a certbot installed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;apt-get remove certbot&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install latest certbot &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;snap install --classic certbot&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add it to your bin, so that it can be executed using certbot command&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;ln -s /snap/bin/certbot /usr/bin/certbot&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can verify the cerbot version&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;certbot --version&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Continue to install ssl certificates for your nginx server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;certbot -–nginx&lt;/code&gt;&lt;br&gt;
This will ask for you email id, in-case you need to be contacted for SSL certificate renewal and notices&lt;br&gt;
Type ‘Y’ for accept terms of service&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It would show the available server-names for which the certificate has to be installed for&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TRiq817F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5dsaf09h032c9f4dizz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TRiq817F--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5dsaf09h032c9f4dizz.png" alt="Image description" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Just press enter and proceed. This would generate a ssl certificate and configure it in the nginx server.&lt;/li&gt;
&lt;li&gt;Now if you access the above website, it would be in https&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C12bX0Un--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tab7w9jmf9je1chm8949.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C12bX0Un--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tab7w9jmf9je1chm8949.png" alt="Image description" width="702" height="261"&gt;&lt;/a&gt;&lt;br&gt;
Finally you have your own website configured in AWS EC2 instance severed through HTTPS protocol.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-7 Auto renew certificate:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can schedule your server to auto renew your SSL/TLS certificate using the following command&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;certbot renew --dry-run&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This would create a timer, which check the SSL certificate expiry periodically and would auto renew it.&lt;/li&gt;
&lt;li&gt;You can verify this by the following command and checking the current timers running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;systemctl list-timers&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--4u-HKOOP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7vdaxsffvtz79y3lhlw4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--4u-HKOOP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7vdaxsffvtz79y3lhlw4.png" alt="Image description" width="800" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ubuntu</category>
      <category>nginx</category>
      <category>letsencrypt</category>
    </item>
  </channel>
</rss>
