<?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: Ashwini Singh</title>
    <description>The latest articles on DEV Community by Ashwini Singh (@ashwinisingh).</description>
    <link>https://dev.to/ashwinisingh</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3198388%2Fd4aa914f-14f8-483c-89f7-c7c7e606e5f9.png</url>
      <title>DEV Community: Ashwini Singh</title>
      <link>https://dev.to/ashwinisingh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashwinisingh"/>
    <language>en</language>
    <item>
      <title>🌐 Secure NGINX Web Server on AWS EC2 with Let's Encrypt SSL and Custom Domain</title>
      <dc:creator>Ashwini Singh</dc:creator>
      <pubDate>Fri, 23 May 2025 07:11:28 +0000</pubDate>
      <link>https://dev.to/ashwinisingh/secure-nginx-web-server-on-aws-ec2-with-lets-encrypt-ssl-and-custom-domain-10pm</link>
      <guid>https://dev.to/ashwinisingh/secure-nginx-web-server-on-aws-ec2-with-lets-encrypt-ssl-and-custom-domain-10pm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Setting up a secure web server is a foundational DevOps skill. In this post, you'll learn how to&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✅ Launch an EC2 instance&lt;br&gt;
✅ Set up NGINX with a custom Hello page&lt;br&gt;
✅ Secure it with a free SSL certificate using Let's Encrypt&lt;br&gt;
✅ Connect your domain using Route 53&lt;/p&gt;


&lt;h2&gt;
  
  
  🧰 Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;AWS account&lt;/li&gt;
&lt;li&gt;A registered domain (Route 53, GoDaddy, etc.)&lt;/li&gt;
&lt;li&gt;PuTTY (Windows) or terminal (Linux/macOS)&lt;/li&gt;
&lt;li&gt;Basic Linux command-line knowledge&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  ☁️ Step 1: Launch an EC2 Instance
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to the AWS EC2 Dashboard&lt;/li&gt;
&lt;li&gt;Click Launch Instance&lt;/li&gt;
&lt;li&gt;Choose OS: Ubuntu 22.04 or Amazon Linux 2&lt;/li&gt;
&lt;li&gt;Select instance type: &lt;code&gt;t3.medium&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Configure in a Public Subnet of a VPC&lt;/li&gt;
&lt;li&gt;Enable inbound rules in the Security Group

&lt;ul&gt;
&lt;li&gt;TCP 22 (SSH)&lt;/li&gt;
&lt;li&gt;TCP 80 (HTTP)&lt;/li&gt;
&lt;li&gt;TCP 443 (HTTPS)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Download the .pem key pair&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  💻 Step 2: Connect via SSH using PuTTY (Windows)
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Open PuTTYgen&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load your .pem file&lt;/li&gt;
&lt;li&gt;Click Save Private Key → this generates .ppk&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Open PuTTY&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Host Name: &lt;code&gt;ubuntu@your-ec2-ip&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Go to Connection → SSH → Auth&lt;/li&gt;
&lt;li&gt;Load the &lt;code&gt;.ppk file&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Click Open → You’re connected&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  🌍 Step 3: Point Domain to EC2
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Go to Route 53 → Hosted Zones&lt;/li&gt;
&lt;li&gt;Click Create Record

&lt;ul&gt;
&lt;li&gt;Type: &lt;code&gt;A&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Name: &lt;code&gt;@&lt;/code&gt; or &lt;code&gt;www&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Value: your &lt;code&gt;EC2 IP&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;📌 Test: Visit &lt;a href="http://yourdomain.com" rel="noopener noreferrer"&gt;http://yourdomain.com&lt;/a&gt; — NGINX default page should appear.&lt;/p&gt;


&lt;h2&gt;
  
  
  🔧 Step 4: Install NGINX + Hello Page
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt update
sudo apt install nginx -y
echo "&amp;lt;h1&amp;gt;Hello from AWS + NGINX&amp;lt;/h1&amp;gt;" | sudo tee /var/www/html/index.html
sudo systemctl restart nginx

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

&lt;/div&gt;


&lt;p&gt;Access it at &lt;code&gt;http://yourdomain.com&lt;/code&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  🔐 Step 5: Add Free SSL with Let’s Encrypt
&lt;/h2&gt;

&lt;p&gt;Install Certbot:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt install certbot python3-certbot-nginx -y

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

&lt;/div&gt;



&lt;p&gt;Run Certbot for your domain:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot --nginx -d yourdomain.com

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

&lt;/div&gt;



&lt;p&gt;Test auto-renewal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo certbot renew --dry-run

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  🧠 Bonus: Editing the NGINX Config
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo vim /etc/nginx/sites-available/default

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

&lt;/div&gt;



&lt;p&gt;Example Config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server {
    listen 80;
    server_name yourdomain.com;

    root /var/www/html;
    index index.html;

    location / {
        try_files $uri $uri/ =404;
    }
}

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

&lt;/div&gt;



&lt;p&gt;Save and reload:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl reload nginx

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  📌 Project Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;📂 /var/www/html/index.html       # Custom hello page
📂 /etc/nginx/sites-available     # NGINX site configs
🔐 SSL: Managed by Certbot
🌐 Domain: Managed via Route 53

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

&lt;/div&gt;






&lt;h2&gt;
  
  
  📊 Architecture Diagram
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ftltz5clxiqvvc5x62r8t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ftltz5clxiqvvc5x62r8t.png" alt="Image description" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🏁 Final Output
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://yourdomain.com

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

&lt;/div&gt;



&lt;p&gt;With NGINX serving your page securely over HTTPS&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;If you found this helpful, please ❤️ or 🦄 and follow for more AWS &amp;amp; DevOps content...&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>vpc</category>
      <category>ec2</category>
      <category>route53</category>
    </item>
  </channel>
</rss>
