<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Chinecherem Udegbunam on Medium]]></title>
        <description><![CDATA[Stories by Chinecherem Udegbunam on Medium]]></description>
        <link>https://medium.com/@ChinecheremU?source=rss-89402fdfd0ec------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*gbdicMX0cTBSMAFkufSQ_Q.jpeg</url>
            <title>Stories by Chinecherem Udegbunam on Medium</title>
            <link>https://medium.com/@ChinecheremU?source=rss-89402fdfd0ec------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 08:55:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ChinecheremU/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Build a Virtual Private Cloud with Python and Linux]]></title>
            <link>https://medium.com/@ChinecheremU/how-to-build-a-virtual-private-cloud-with-python-and-linux-f2ebd9958389?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f2ebd9958389</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[linux-namespace]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Wed, 12 Nov 2025 14:18:23 GMT</pubDate>
            <atom:updated>2025-11-12T14:18:23.202Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve all done it. You log into AWS, create a VPC, add subnets, attach a NAT and Internet Gateway, and set up routes in route tables. It all just works.</p><p>But what <em>is</em> a VPC? What’s really happening under the hood?</p><p>Well, the answer to that question is what this post will talk about. This article will explain how to build a <strong>VPC, with public/private subnets, NAT, security groups/firewalls, and even peering, using only a single Python script on one Linux server.</strong></p><h3>The Architecture: How a VPC is Really Built</h3><p>While doing this task and before I wrote any code, I needed a blueprint. The “secret” is that all the complex cloud networking features are just user-friendly names for fundamental Linux tools that have existed for decades.</p><p>Here are the building blocks:</p><ul><li><strong>The VPC Itself:</strong> This isn’t a box. It’s just a <strong>Linux Bridge. </strong>Think of it as a virtual network switch that all your subnets plug into.</li><li><strong>The Subnet:</strong> This isn’t a physical router. It’s a <strong>Network Namespace</strong>. An easy analogy is to think of your Linux server as a large apartment building. A namespace is like building a new, isolated &quot;room&quot; inside that building. It has its own private set of network interfaces, routing tables, and firewall rules.</li><li><strong>The “Cable”:</strong> To connect a “room” (namespace) to the building’s “switch” (bridge), you use a <strong>veth pair</strong>. This is just a virtual ethernet cable. One end goes in the namespace, the other plugs into the bridge.</li><li><strong>The Router:</strong> The host Linux server <em>itself</em> is the master router for everything. I enabled IP forwarding to allow the kernel move packets between the virtual interfaces.</li></ul><h4>The Architectural Diagram</h4><p>Here is a pictorial model for the setup.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*TsNulCwExLlGhkD-qY328Q.png" /><figcaption>VPC Concept on Linux</figcaption></figure><ol><li><strong>The Host (EC2 Instance or any Linux server):</strong> The big box. It has its main network card connected to the real internet.</li><li><strong>Inside the Host (The VPCs):</strong> There are two bridges, <strong>br-vpc-demo</strong> and <strong>br-vpc-dev</strong>. These are the two separate VPCs.</li><li><strong>Inside the VPCs (The Subnets):</strong></li></ol><ul><li><strong>br-vpc-demo</strong> has two namespaces plugged into it: <strong>ns-vpc-demo-public</strong> and <strong>ns-vpc-demo-private</strong>.</li><li><strong>br-vpc-dev</strong> has one namespace: <strong>ns-vpc-dev-private</strong>.</li></ul><p><strong>4. The “Special” Connections:</strong></p><ul><li><strong>NAT:</strong> An iptables rule on the <em>Host</em> translates traffic from ns-vpc-demo-public so it can use the host&#39;s internet, like a PO Box.</li><li><strong>Security Group:</strong> An iptables firewall <em>inside</em> the namespaces prevents unknown traffic from coming in.</li><li><strong>Peering:</strong> An iptables rule on the <em>Host</em> gives br-vpc-demo permission to talk to br-vpc-dev.</li></ul><h3>The Tool: Building vpcctl.py</h3><p>I automated all of this with a Python script. Here’s how it works, step-by-step.</p><h4>1. Creating the VPC (The Bridge)</h4><p>The first command, <strong>create-vpc</strong>, does two simple things.</p><p>a. Creates the bridge:</p><pre>ip link add name br-vpc-demo type bridge </pre><p>b. Sets up the VPC isolation rules:</p><pre>iptables -I FORWARD -i br-vpc-demo ! -o br-vpc-demo -j DROP</pre><p>This is the most important rule. It’s a “default deny” for the whole VPC. It says: “If a packet comes in from this VPC, it is not allowed to go out to any interface that isn’t also part of this VPC. DROP it.” This is what isolates vpc-demo from vpc-dev.</p><h4>2. Creating Subnets (Namespaces)</h4><p>The <strong>create-subnet</strong> command is where the magic happens.</p><p>a. It creates a new namespace (room):</p><pre>ip netns add ns-vpc-demo-private</pre><p>b. It creates the veth pair (cable):</p><pre>ip link add veth-vppr688-ns type veth peer name veth-vppr688-br</pre><p>c. It puts one end in the namespace and assigns it an IP:</p><pre>ip link set veth-vppr688-ns netns ns-vpc-demo-private</pre><p>d. It plugs the other end into the bridge:</p><pre>ip link set veth-vppr688-br master br-vpc-demo</pre><p>It adds a “gateway” IP (e.g., <strong>10.100.2.1</strong>) to the <em>bridge</em>, so the namespace knows where to send its traffic.</p><h4>3. The “Public” Subnet (NAT)</h4><p>What makes a subnet “public”? It’s not special. It’s just one iptables rule on the host:</p><pre>iptables -t nat -I POSTROUTING -s 10.100.1.0/24 -o enX0 -j MASQUERADE</pre><p>Analogy:</p><p>Think of your host’s IP as a public-facing PO Box for your apartment building.</p><p>A packet from the “private” subnet tries to go to <strong>google.com</strong>. It has a &quot;From&quot; address of <strong>10.100.2.2</strong>. The internet doesn&#39;t know how to send a reply to that private address, so the packet dies.</p><p>A packet from the “public” subnet does the same. When it hits the host, <strong>MASQUERADE</strong> rewrites the &quot;From&quot; address to be the <em>host&#39;s</em> public IP. Google sends the reply back to the host, which then remembers to forward it to the correct &quot;public&quot; namespace.</p><h4>4. Security Groups (The Bouncer)</h4><p>The <strong>apply-firewall </strong>command reads a simple JSON file and applies it as a firewall <em>inside</em> the namespace.</p><ol><li><strong>Default Deny:</strong> When you create a subnet, you first set its internal policy to <strong>DROP </strong>all incoming traffic.</li><li>Allow Rules: The policy.json (e.g., {“port”: 80, “action”: “accept”}) tells the script to add an ACCEPT rule inside the namespace.</li><li>This is exactly how a Security Group works: it’s a stateful, default-deny firewall that lives on the “instance” (the namespace) itself.</li></ol><h4>5. VPC Peering (The Hallway)</h4><p>This was the final test. There are two isolated VPCs (br-vpc-demo and br-vpc-dev). How do you connect them?</p><p>Well, you just add an ACCEPT rule that is more specific than the main DROP rule.</p><pre>iptables -I FORWARD -i br-vpc-demo -o br-vpc-dev -j ACCEPT</pre><p>This rule says: “Hey, that main DROP rule? Ignore it for a second. If a packet is going from <strong>br-vpc-demo</strong> <em>specifically</em> to <strong>br-vpc-dev</strong>, <strong>ACCEPT it</strong>.&quot;</p><p>That’s it. The command builds a secure hallway between the two isolated VPCs.</p><h3>Let’s Get Our Hands Dirty: A Step-by-Step Guide to Setup a VPC on a Linux Host</h3><p>Reading about it is one thing, but <em>doing</em> it is where you really learn. Here’s how you can run this entire project yourself in just a few minutes.</p><p>All you need is a Linux server (like a fresh Amazon EC2 instance) and my <strong><em>vpc-builder</em></strong> repository.</p><h4>Prerequisites</h4><ol><li><strong>Get the code:</strong></li></ol><pre>git clone https://github.com/cf-cloud89/vpc-builder.git</pre><pre>cd vpc-builder</pre><p>2. Make the script executable:</p><pre>chmod +x vpcctl.py</pre><p>3. Install dependencies:</p><pre><br>sudo yum install iptables make -y</pre><p><strong>Crucial Step:</strong> Open the <strong>Makefile</strong> with <em>nano Makefile</em> and change the <strong>IFACE </strong>variable to your host&#39;s main internet interface (like <em>enX0</em><strong><em> </em></strong>or <em>eth0</em>).</p><p>To get your host’s main internet interface, run:</p><pre>ip a</pre><h3>Part 1: The Automated Way (Using the Makefile)</h3><p>This is the fastest way to do the task. The <strong>Makefile </strong>automates all the tests for you.</p><h4>Test 1: Public/Private Subnets &amp; NAT</h4><p>This test will create the first VPC and check if the public subnet can get to the internet while the private one stays offline.</p><p><strong>1. Run the setup:</strong></p><pre>sudo make setup</pre><p>This command calls the <strong>vpcctl.py</strong> script to build the <strong>vpc-demo</strong> bridge and create both the <em>public</em> and <em>private </em>subnets (namespaces).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b2iPZv0nQLfOIlZwu5K3oQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X10c1gJD4eY5PTwohDLfrA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avjisW_mgf5_J9ObXl0lrQ.png" /></figure><p>2. Test the Public Subnet:</p><p>Let’s see if the public subnet can reach Google.</p><pre>sudo ip netns exec ns-vpc-demo-public ping -c 3 8.8.8.8</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*a7-BsWuE9Fbk3o6yYgsOjg.png" /></figure><p>Result: It works! 0% packet loss. The MASQUERADE (NAT) rule is correctly rewriting the &quot;From&quot; address, so Google can send a reply.</p><p>3. Test the Private Subnet:</p><p>Now, let’s try the exact same ping from the private subnet.</p><pre>sudo ip netns exec ns-vpc-demo-private ping -c 3 8.8.8.8</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zm6CXRR3oItChj31UGJVdA.png" /></figure><p>Result: 100% packet loss. It fails completely. This is perfect! It has no NAT rule, so it’s totally isolated from the internet</p><p>4. Test the Inter-Subnet Routing:</p><pre>sudo ip netns exec ns-vpc-demo-private ping -c 3 8.8.8.8</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tOlPmvBbZPm108sufFxQjQ.png" /></figure><p>Result: 0% packet loss. This shows the private subnet can route traffic to the public subnet’s gateway via the bridge.</p><h4>Test 2: Security Groups</h4><p>Now let’s see if we can block and allow traffic to the private subnet, just like an AWS Security Group.</p><p>1. Start a Server:</p><p>First, start a simple web server inside the private subnet.</p><pre>sudo ip netns exec ns-vpc-demo-private python3 -m http.server 80 &amp;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cf-2yPA-DTIhEMtds4ns1w.png" /></figure><p>2. Test “Before” (Blocked):</p><p>Try to curl that server from the host machine.</p><pre>curl --connect-timeout 2 http://10.100.2.2:80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PFWchZqekhMLzap4_JoXmg.png" /></figure><p>Result: Connection timed out. This is like the “bouncer” (the iptables -P INPUT DROP rule) doing its job. It’s set to &quot;default-deny,&quot; so it’s dropping all new traffic.</p><p>3. Apply the Firewall Rule:</p><p>Now, let’s tell the bouncer that port 80 is on the guest list.</p><pre>sudo make apply-firewall</pre><p>This command creates a <em>policy.json</em> file and runs the script to apply the <strong>ACCEPT</strong> rule for port 80 <em>inside</em> the namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YBg5mFoUnp2JP6avTUJ1NQ.png" /></figure><p>4. Check If the policy.json File was Created Successfully:</p><pre>ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fTqr1mies0M5fypGaUYLTQ.png" /></figure><p>5. Test “After” (Allowed):</p><p>Try the curl again.</p><pre>curl http://10.100.2.2:80</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LIWmRCbQwfqtjBmdk5EM9A.png" /></figure><p>Result: Success! It instantly returns the HTML. The apply-firewall command successfully modified the “security group” for the subnet.</p><p>6. Clean Up:</p><p>Run the cleanup command to delete the VPC resources provisioned so far.</p><pre>sudo make cleanup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4VBqsej5BYv5EFP-eRGWA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QXBByiKvuE-S8p-gsZW0ZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ErEbH_6Db8p6YFn3gz_XZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZYxdXL56mlTL9xXrleBaFA.png" /></figure><h4>Test 3: VPC Peering (The Hallway)</h4><p>This is the big one. In this part, you’ll create a second VPC and connect it to the first one.</p><ol><li>Run Peering Setup:</li></ol><p>This command builds both VPCs: vpc-demo and vpc-dev, plus 2 subnets (public/private) inside vpc-demo, and 1 subnet (private) inside vpc-dev. It does not connect them.</p><pre>sudo make setup-peering</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9nENjVHnnq-3QQJX-gzdMw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PejUMZTPMtSnQARPw0uNag.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qb2go4AzvKsI296rmFY7w.png" /></figure><p>2. Test “Before” (Isolation):</p><p>Check if the VPCs are isolated. Ping vpc-dev from vpc-demo.</p><pre>sudo ip netns exec ns-vpc-demo-private ping -c 3 10.200.1.1</pre><p><strong>Result:</strong> 100% packet loss. This is the main VPC isolation rule (<em>DROP ... ! -o br-vpc-demo</em>) working perfectly.</p><p>3. Apply VPC Peering:</p><p>Now, let’s build the “hallway.” Run the peer-vpc command manually.</p><pre>sudo ./vpcctl.py peer-vpc --vpc-a vpc-demo --vpc-b vpc-dev</pre><p>This adds the two <strong>ACCEPT </strong>rules to the host’s firewall to create an exception for the <strong>DROP </strong>rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QWSrwOGzVXsynrX11umCg.png" /></figure><p>4. Test “After” (Peering):</p><p>Run the exact same ping one more time.</p><pre>sudo ip netns exec ns-vpc-demo-private ping -c 3 10.200.1.1</pre><p><strong>Result:</strong> 0% packet loss! The ping now works. Two completely separate virtual networks are now peered.</p><p>5. Clean Up:</p><p>Run the cleanup-peering command to remove both provisioned VPCs and other related resources.</p><pre>sudo make cleanup-peering</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2jYvFI6rV9avKeMAYOXYsw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tcl3OEzZhW_SiYITV7ujDg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hGZIzieOWPEwaTsBk2frQw.png" /></figure><h3>Part 2: The Manual Way (A Quick Reference)</h3><p>The <strong>Makefile </strong>is just a shortcut for running the <strong>vpcctl.py</strong> script. If you want to type the commands manually, here are the exact commands.</p><p>1. Create a VPC (The Bridge):</p><pre>sudo ./vpcctl.py create-vpc — name vpc-demo — cidr 10.100.0.0/16</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vD88I24lB0yVvjcosSAMhw.png" /></figure><p>2. Create Subnets (The Rooms):</p><p>Public subnet:</p><pre>sudo ./vpcctl.py create-subnet — vpc vpc-demo — name public — cidr 10.100.1.0/24 — type public — internet-iface enX0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CzpOkGGuLPYdvR6AYfm2bA.png" /></figure><p>Private subnet:</p><pre>sudo ./vpcctl.py create-subnet — vpc vpc-demo — name private — cidr 10.100.2.0/24 — type private</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q4WxBELC8IuohjAjan4bGQ.png" /></figure><p>3. Apply a Firewall Rule (The Bouncer):</p><pre>sudo ./vpcctl.py apply-rules — policy ./policy.json</pre><p>4. Peer Two VPCs (The Hallway):</p><pre>sudo ./vpcctl.py peer-vpc — vpc-a vpc-demo — vpc-b vpc-dev</pre><p>5. Cleanup (The Teardown):</p><p>Note:<strong> Delete</strong> subnets first before deleting the VPC.</p><pre># Delete the subnets first<br>sudo ./vpcctl.py delete-subnet --vpc vpc-demo --name public --cidr 10.100.1.0/24 --internet-iface enX0<br>sudo ./vpcctl.py delete-subnet --vpc vpc-demo --name private --cidr 10.100.2.0/24</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*31TWjjPWlGz8WlHHoanNgQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DHPiCuA8VtUIrP6sGY1suA.png" /></figure><pre># Then delete the empty VPC<br>sudo ./vpcctl.py delete-vpc --name vpc-demo</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTtRFB1Y8VoacMqVXc0eAQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02EFIBHNryviAV-Y-hqNJw.png" /></figure><h3>What I Learned (I encountered bugs and it was the best part)</h3><p>I did a lot of debugging in this project. Every time I got an error while testing the Python functions, I learned a new, fundamental concept about Linux networking.</p><p>But one that stood out for me was the debugging I did about <strong>interface names having a 15-character limit.</strong> My clever veth names (<strong>veth-vpc-demo-public-br</strong>) were too long. The kernel rejected them. I learned about the <em>IFNAMSIZ </em>limit and fixed it by using a readable hash (<strong>veth-vppuffe-br</strong>).</p><h3>Conclusion</h3><p>A VPC is simply a bridge. A subnet is a namespace. A gateway is an <em>iptables</em> rule. It’s all just layers of brilliant, open-source Linux tools.</p><p>Building this <strong>vpcctl</strong> tool was one of the most frustrating and rewarding things I’ve done. I not only learned <em>how</em> a VPC works under-the-hood, but <em>why</em> it’s designed the way it is.</p><p>If you want to see for yourself, you can check out the complete project, including the <strong>vpcctl.py </strong>script and the <strong>Makefile</strong> to run all these tests yourself, on my GitHub.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f2ebd9958389" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Day 36–40) 100 Days of DevOps Challenge by KodeKloud]]></title>
            <link>https://medium.com/@ChinecheremU/day-36-40-100-days-of-devops-challenge-by-kodekloud-6e0e933e14d7?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e0e933e14d7</guid>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Fri, 07 Nov 2025 12:56:22 GMT</pubDate>
            <atom:updated>2025-11-07T12:56:22.584Z</atom:updated>
            <content:encoded><![CDATA[<p>Days 36–40 of the <a href="https://kodekloud.com/100-days-of-devops"><strong>100 Days of DevOps Challenge by KodeKloud</strong></a> focused on mastering Docker fundamentals through hands-on container operations. The tasks encompass deploying an Nginx container, copying files into running containers, pulling images from Docker Hub, creating custom images from modified containers, and executing commands inside containers.<br>These exercises provided practical experience with core Docker commands and workflows, which are essential skills for managing containerized applications in real-world DevOps environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SjaNkwCL-fA6qboF.png" /><figcaption>100 Days of DevOps with KodeKloud</figcaption></figure><h3>Day 36: Deploy an Nginx Container on App Server 2</h3><p>After setting up Docker in the Day 35 task, the Nautilus DevOps team proceeded to perform their first real container deployment. The goal for the Day 36 task was simple but essential: run an Nginx container to verify that Docker is functioning correctly on the server.</p><p>Here’s how to complete the task:</p><h4>Step 1: SSH into App Server 2</h4><p>Run:</p><pre>ssh steve@stapp02</pre><p>Then add the user to the Docker group so you can run Docker commands without sudo:</p><pre>sudo usermod -aG docker $USER</pre><h4>Step 2: Pull the nginx alpine image from Docker Hub</h4><pre>docker pull nginx:alpine</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*7pZPy6oGBSBzj6rEnvw4AA.png" /></figure><p><strong>Note: </strong>This image is optimized for a smaller size and faster startup, making it ideal for quick tests and minimal environments.</p><h4>Step 3: Run the nginx container</h4><p>Launch a container named <strong>nginx_2 w</strong>ith the downloaded Docker image:</p><pre>docker run -d --name nginx_2 nginx:alpine</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*Xj0O5fVtoMIOlhsZnzHu1A.png" /></figure><p><strong>Command breakdown:</strong></p><ul><li><strong>-d</strong> — runs the container in detached mode (in the background)</li><li><strong>--name nginx_2</strong> — assigns a custom name to the container</li><li><strong>nginx:alpine</strong> — specifies the image to use</li></ul><h4>Step 4: Verify the container status</h4><p>To confirm that the container was up and running:</p><pre>docker ps</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*D1jv8an_Vuk4uxfA9Q-UPA.png" /></figure><p>The Nginx service is now live inside a lightweight Alpine-based container, which confirms that Docker is successfully managing and running workloads on <strong>App Server 2</strong>.</p><h3>Day 37: Copy Encrypted File to a Running Ubuntu Container</h3><p>Day 37 task focused on transferring an <strong>encrypted file</strong> from the Docker host to a running container without altering its contents.</p><p>Here are the steps to complete the task:</p><h4>1. SSH into App Server 2</h4><pre>ssh steve@stapp02</pre><p>Then add the user to the Docker group so you can run Docker commands without sudo:</p><pre>sudo usermod -aG docker $USER</pre><h4>2. Verify the running container</h4><p>To confirm that the <strong>ubuntu_latest</strong> container is active, run:</p><pre>docker ps</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*73VTOh1ia-IWOb-M93-TEw.png" /></figure><h4>3. Locate the file to be copied</h4><p>The confidential, encrypted file was stored on the Docker host at:</p><pre>/tmp/nautilus.txt.gpg</pre><p>Verify its presence before copying by running:</p><pre>ls -l /tmp/nautilus.txt.gpg</pre><p>Expected Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*3OOiO4lfHHpenz8JxosDQg.png" /></figure><h4>4. Copy the file into the container</h4><p>The goal was to copy the file <em>as-is</em> — without decrypting, modifying, or altering permissions.</p><p>Use the <strong>docker cp</strong> command:</p><pre>docker cp /tmp/nautilus.txt.gpg ubuntu_latest:/home/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*GHiL48IkG-U6XzPRVsyWrg.png" /></figure><p><strong>Command breakdown:</strong></p><ul><li><strong>docker cp</strong> — copies files between the Docker host and a container</li><li><strong>/tmp/nautilus.txt.gpg</strong> — source path on the Docker host</li><li><strong>ubuntu_latest:/home/</strong> — destination path inside the container</li></ul><h4>5. Confirm the file inside the container</h4><p>After copying, verify that the file exists and remains intact inside the container:</p><pre>docker exec -it ubuntu_latest ls -l /home/</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*HGGaSnJTd8IJ-okyPtZ10A.png" /></figure><p>For an additional integrity check (<em>optional</em>), compare the file’s checksum between the host and container by running:</p><pre>sha256sum /tmp/nautilus.txt.gpg<br>docker exec ubuntu_latest sha256sum /home/nautilus.txt.gpg</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*qfcdf0bMaoXQf7EJjs6mew.png" /></figure><p>Both hashes matched, which confirms that no modification occurred.</p><h3>Day 38: Pull and Retag a Docker Image</h3><p>Day 38’s task focuses on pulling a specific Docker image and creating a new tag for it, which is a common practice in image version control and environment setup. It also ensures that developers can reference the same image under a simplified or environment-specific tag without duplicating the image data.</p><p>Here’s how to complete the task:</p><h4>1. SSH into App Server 3</h4><pre>ssh banner@stapp03</pre><p>Then add the user to the Docker group so you can run Docker commands without sudo:</p><pre>sudo usermod -aG docker $USER</pre><h4>2. Pull the specified image</h4><pre>docker pull busybox:musl</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*A_ryiRr4okNqWTrWrgg8sA.png" /></figure><h4>3. Re-tag the image</h4><p>Create a new tag named <strong>news </strong>using the <strong>docker tag</strong> command:</p><pre>docker tag busybox:musl busybox:news</pre><p>This doesn’t duplicate the image; it simply creates a new label that references the same image ID.</p><h4>4. Verify the tag</h4><p>List all images to confirm both tags now exist:</p><pre>docker images</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*6g0kNnkesyAYv21Iuuqajw.png" /></figure><p>Notice that both <strong>musl</strong> and <strong>news</strong> share the <strong>same IMAGE ID</strong>, which confirms that the retagging worked correctly.</p><h3>Day 39: Create a New Docker Image from a Running Container</h3><p>The task was to <strong>capture the container’s current state into a new Docker image</strong> — a common practice for quick backups or promoting prototype environments. It ensures that all changes made inside the container, such as installed packages, modified files, or configurations, are saved permanently as an image.</p><p>Here are the steps to follow to complete the task:</p><h4>1. SSH into App Server 3</h4><pre>ssh banner@stapp03</pre><p>Then add the user to the Docker group so you can run Docker commands without sudo:</p><pre>sudo usermod -aG docker $USER</pre><h4>2. Check the running container</h4><p>Before creating an image, confirm the target container is running:</p><pre>docker ps</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*HtTedHafCGXdn3JG3PgW9w.png" /></figure><p><strong>Note:</strong> If it’s stopped, start it again with:</p><pre>docker start ubuntu_latest</pre><h4>3. Commit the container as an image</h4><p>To capture the container’s current filesystem and create a new Docker image, use the <strong>docker commit</strong> command:</p><pre>docker commit ubuntu_latest demo:nautilus</pre><p><strong>Command breakdown:</strong></p><ul><li><strong>docker commit</strong> — saves a container’s state as a new image.</li><li><strong>ubuntu_latest</strong> — source container name.</li><li><strong>demo:nautilus</strong> — repository (demo) and tag (nautilus) for the new image.</li></ul><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*jiOAKdEEcWsLfDyGIFEyzA.png" /></figure><h4>4. Verify the new image</h4><p>To confirm that the image was successfully created, run:</p><pre>docker images</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*jMO04irb7XDP8g22-kerSw.png" /></figure><p>The new image now serves as a portable, restorable version of the developer’s test environment, ready to be reused, shared, or deployed later.</p><h3>Day 40: Configure Apache to Run on a Custom Port Inside a Docker Container</h3><p>Day 40’s task was to install and configure <strong>Apache (httpd)</strong> to listen on a <strong>non-default port</strong>.</p><p><strong>The requirements:</strong></p><ol><li>Install <strong>Apache2</strong> inside the container.</li><li>Configure Apache to <strong>listen on port 5003</strong> instead of 80.</li><li>Do <strong>not</strong> restrict binding; it should listen on all interfaces (0.0.0.0, 127.0.0.1, localhost, container IP, etc.).</li><li>Ensure Apache service is running, and keep the container running at the end.</li></ol><p>Here are the steps to follow to get the task done:</p><h4>1. SSH into App Server 1</h4><pre>ssh tony@stapp01</pre><p>Then add the user to the Docker group to be able to run Docker commands without sudo:</p><pre>sudo usermod -aG docker $USER</pre><h4>2. Access the running container</h4><p>List containers to confirm that <strong>kkloud</strong> is running:</p><pre>docker ps</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*nsjq3aWX8eq9as1f2Cvm5w.png" /></figure><h4>3. Update packages and install Apache2</h4><p>First, enter the container shell:</p><pre>docker exec -it kkloud bash</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*aP27P1oN1jmSjiuNvaQOyA.png" /></figure><p>Once inside the container shell, update package lists and install Apache:</p><pre>apt update<br>apt install apache2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*jpPPC52Zeda1Hedny1j21w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*KuescbcI6qgnWeEpMMHbSg.png" /></figure><p>You can verify Apache installation with:</p><pre>apache2 -v</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*Aw7OMwBV-TZKqhG3GCyXNg.png" /></figure><h4>4. Start the Apache service</h4><pre>service apache2 start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*P-9Wa81KoFKHjxQEz7y2bA.png" /></figure><h4>5. Change Apache listening port</h4><p>By default, Apache listens on port <strong>80</strong>. Reconfigure it to listen on <strong>5003 </strong>(as per the requirements) by editing the ports configuration file:</p><pre>vi /etc/apache2/ports.conf</pre><p>Find the line:</p><pre>Listen 80</pre><p>Change it to:</p><pre>Listen 5003</pre><p>Next, update the <strong>default virtual host</strong> configuration:</p><pre>vi /etc/apache2/sites-enabled/000-default.conf</pre><p>Locate the line:</p><pre>&lt;VirtualHost *:80&gt;</pre><p>and change it to:</p><pre>&lt;VirtualHost *:5003&gt;</pre><p>Save and exit.</p><h4>6. Restart Apache to apply changes and verify</h4><pre>service apache2 restart</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*e97XJU7ucOLnCrAWEI4ZNA.png" /></figure><p>Now confirm it’s running:</p><pre>service apache2 status</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*_XIuAhuWNsZlAN2yUmkP2g.png" /></figure><p>Check that it’s listening on port 5003:</p><pre>netstat -tuln | grep 5003</pre><p><strong>Expected output:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*R44CxKSfub0Y3jKS9806Wg.png" /></figure><p>or, if <strong>netstat</strong> is unavailable:</p><pre>ss -tuln | grep 5003</pre><p>If none of the packages are installed in the container, install either of them using:</p><pre>apt install net-tools # To install netstat<br>apt install iproute2  # To install ss (socket statistics)</pre><h4>6. Keep the container running</h4><p>Exit the container shell, but make sure it remains active:</p><pre>exit<br>docker ps</pre><p>If the container runs in interactive mode and stops on exit, restart it detached:</p><pre>docker start kkloud</pre><p>This task reinforces an important DevOps concept<strong>: service configuration within containers</strong>. Even though containers are lightweight and disposable, you can still modify configurations inside them for debugging or legacy setups.</p><p>However, in production pipelines, such configurations are better handled using <strong>Dockerfiles</strong> and <strong>environment variables</strong> for consistency and reproducibility.</p><p>If this guide helped you scale through the challenge, tap the clap icon (👏) multiple times and check my page for Day 41 task!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e0e933e14d7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a Real-Time Slack Alerter for an Nginx Proxy (The Lightweight Way)]]></title>
            <link>https://medium.com/@ChinecheremU/how-i-built-a-real-time-slack-alerter-for-an-nginx-proxy-the-lightweight-way-f52cced60fa7?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/f52cced60fa7</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Tue, 04 Nov 2025 15:33:48 GMT</pubDate>
            <atom:updated>2025-11-04T15:33:48.753Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Note: This project is a continuation of a Blue/Green deployment task I worked on and documented. Check the GitHub link <a href="https://github.com/cf-cloud89/blue-green-deployment-with-nginx">here</a>. I also wrote how I did it in this <a href="https://medium.com/@ChinecheremU/how-i-set-up-a-resilient-blue-green-deployment-with-docker-compose-and-nginx-9726a9a068bf">Medium article</a>. The task was about how to set up a resilient Blue/Green deployment with Docker Compose and Nginx. Meanwhile, this article you’re about to read explains the part of “adding observability” to the project.</blockquote><blockquote>If you wish to implement what’s in this piece, you may want to check and do the first part before you continue with this one.</blockquote><p>If you’ve ever set up a high-availability system like a Blue/Green deployment, you know the magic of <strong>Nginx’s proxy_pass</strong>. If your primary “Blue” server fails, Nginx <em>instantly</em> and <em>silently </em>fails over to your “Green” server.</p><p>The user never sees an error. It’s perfect.</p><p><strong>Except for one problem:</strong> it’s silent.</p><p>How do you know it failed? How long have you been running on your backup server? Are you one app_green crash away from a total outage?</p><p>In this guide, I will show you how I built a lightweight, powerful “watcher” service that gives the silent proxy a voice. I will explain how I built a system that tails Nginx logs in real-time and sends actionable alerts to Slack for:</p><p>➡FAILOVER: When the primary app fails.<br>➡RECOVERY: When the primary app comes back online.<br>➡ERROR RATE: When the app is throwing too many server errors.</p><p>I will do all of it using Docker Compose and a simple Python script, with no expensive logging platform required.</p><h3>The Project Architecture</h3><p><strong>Nginx:</strong> I configured Nginx to write its logs in a structured JSON format. This makes them easy for a computer to read.<br><strong>Docker Volume:</strong> I created a shared “volume” that both Nginx and the new Python service can access. Nginx will write its JSON logs to this volume.<br><strong>Python Watcher:</strong> This is the new service. It’s a simple Python script that reads from the shared volume. It will “tail” the log file, parse each new line, track the system’s state, and fire alerts.<br><strong>Slack:</strong> When the watcher sees a problem (like a pool flip or too many 5xx errors), it will send a formatted message to a Slack webhook.</p><p>The plan was simple. I added a new service to the docker-compose.yml file I used in the <a href="https://github.com/cf-cloud89/blue-green-deployment-with-nginx">previous project</a> <a href="https://medium.com/@ChinecheremU/how-i-set-up-a-resilient-blue-green-deployment-with-docker-compose-and-nginx-9726a9a068bf">mentioned above</a>, which acts as a “sidecar.” It will read the logs that Nginx produces and take action based on them.</p><h3>Steps I Followed to Do the Project</h3><h4>Step 1: Get the Slack webhook URL</h4><p>This is like the “phone number” for Slack in the set up.</p><ol><li>I added a new webhook to the channel that was created for us to test the observability and alerts feature (i.e. it can be any Slack channel).</li><li>I copied the webhook URL. It looks like this: <a href="https://hooks.slack.com/services/...%60">https://hooks.slack.com/services/...</a>.</li></ol><h4>Step 2: Set up the environment</h4><p>First, I needed to tell the app where to send alerts. I edited and added these new variables to the <strong>.env.example</strong> file.</p><pre>SLACK_WEBHOOK_URL=&quot;&quot;<br>ERROR_RATE_THRESHOLD=2<br>WINDOW_SIZE=200<br>ALERT_COOLDOWN_SEC=300<br>MAINTENANCE_MODE=false</pre><p>Then copied everything from it to a <strong>.env</strong> file. Additionally, I copied and pasted the Slack URL into the SLACK_WEBHOOK_URL variable in the .env file.</p><p><strong>Note: </strong>Since the .env file contained the Slack webhook URL, which is a secret, I added the <em>.env</em> to <strong>.gitignore</strong> so it doesn’t ever get committed to GitHub.</p><h4>Step 3: Update the docker-compose.yml file</h4><p>This is where I connected everything. I needed to add the new alert_watcher service and the nginx-logs volume. This is the new code after the edits I made to the file:</p><pre>services:<br>  app_blue:<br>    image: ${BLUE_IMAGE}<br>    container_name: app_blue<br>    ports:<br>      - &quot;8081:${PORT}&quot;<br>    environment:<br>      - PORT=${PORT}<br>      - RELEASE_ID=${RELEASE_ID_BLUE}<br>      - APP_POOL=blue<br>    networks:<br>      - app-network<br><br>  app_green:<br>    image: ${GREEN_IMAGE}<br>    container_name: app_green<br>    ports:<br>      - &quot;8082:${PORT}&quot;<br>    environment:<br>      - PORT=${PORT}<br>      - RELEASE_ID=${RELEASE_ID_GREEN}<br>      - APP_POOL=green<br>    networks:<br>      - app-network<br><br>  nginx_proxy:<br>    image: nginx:1.25.3-alpine<br>    container_name: nginx_proxy<br>    ports:<br>      - &quot;8080:80&quot;<br>    environment:<br>      - PORT=${PORT}<br>      - ACTIVE_POOL=${ACTIVE_POOL}<br>    volumes:<br>      - ./nginx.conf.template:/etc/nginx/templates/default.conf.template<br>      - ./nginx-init.sh:/nginx-init.sh<br>      # Mount the shared log volume so Nginx can write to it<br>      - nginx-logs:/var/log/nginx<br>    command: /bin/sh /nginx-init.sh<br>    networks:<br>      - app-network<br>    depends_on:<br>      - app_blue<br>      - app_green<br><br>  alert_watcher:<br>    image: python:3.9-slim-buster<br>    container_name: alert_watcher<br>    working_dir: /app<br>    volumes:<br>      # Mount the watcher script and requirements<br>      - ./watcher.py:/app/watcher.py<br>      - ./requirements.txt:/app/requirements.txt<br>      # Mount the shared log volume (read-only)<br>      - nginx-logs:/var/log/nginx:ro<br>    # On start, install deps and run the watcher<br>    command: sh -c &quot;pip install -r requirements.txt &amp;&amp; python watcher.py&quot;<br>    environment:<br>      # Pass all the .env variables to the script<br>      - SLACK_WEBHOOK_URL=${SLACK_WEBHOOK_URL}<br>      - ACTIVE_POOL=${ACTIVE_POOL}<br>      - ERROR_RATE_THRESHOLD=${ERROR_RATE_THRESHOLD}<br>      - WINDOW_SIZE=${WINDOW_SIZE}<br>      - ALERT_COOLDOWN_SEC=${ALERT_COOLDOWN_SEC}<br>      - MAINTENANCE_MODE=${MAINTENANCE_MODE}<br>    networks:<br>      - app-network<br>    depends_on:<br>      - nginx_proxy<br><br>networks:<br>  app-network:<br>    driver: bridge<br><br># Define the named volume<br>volumes:<br>  nginx-logs:</pre><h4>Step 4: Configure nginx for JSON logging</h4><p>At this step, I told Nginx what to write. I edited the nginx.conf.template file to define the json_logs format and tell Nginx to use it.</p><p>I updated these sections:</p><pre># 1. Define the new JSON log format and capture all the fields required by the task<br>log_format json_logs escape=json<br>  &#39;{&#39;<br>    &#39;&quot;time&quot;: &quot;$time_iso8601&quot;,&#39;<br>    &#39;&quot;client_ip&quot;: &quot;$remote_addr&quot;,&#39;<br>    &#39;&quot;request&quot;: &quot;$request&quot;,&#39;<br>    &#39;&quot;status&quot;: &quot;$status&quot;,&#39;<br>    &#39;&quot;request_time&quot;: &quot;$request_time&quot;,&#39;<br>    # Upstream (App) Specific Data<br>    &#39;&quot;pool&quot;: &quot;$upstream_http_x_app_pool&quot;,&#39;<br>    &#39;&quot;release&quot;: &quot;$upstream_http_x_release_id&quot;,&#39;<br>    &#39;&quot;upstream&quot;: &quot;$upstream_addr&quot;,&#39;<br>    &#39;&quot;upstream_status&quot;: &quot;$upstream_status&quot;,&#39;<br>    &#39;&quot;upstream_response_time&quot;: &quot;$upstream_response_time&quot;&#39;<br>  &#39;}&#39;;<br><br>upstream my_app {<br>    # Set aggressive timeouts for fast testing<br>    server app_blue:${PORT}  ${BLUE_STATUS}  max_fails=200 fail_timeout=2s;<br>    server app_green:${PORT} ${GREEN_STATUS} max_fails=200 fail_timeout=2s;<br>}<br><br>server {<br>    listen 80;<br><br>    # 2. Tell Nginx to use the new format and log to the shared volume<br>    # This file will be read by the alert_watcher container<br>    access_log /var/log/nginx/access.log json_logs;<br><br>    location / {<br> # (rest of the location block).....</pre><h4>Step 5: Fix the nginx log “stream”</h4><p>This was a crucial ‘gotcha’ moment for me. The official nginx:alpine image doesn’t log to a real file. It logs to a stream (/dev/stdout), which the Python script can’t “tail” properly.</p><p>For that reason, I edited the nginx-init.sh script to delete that stream and create a real, empty file before Nginx starts.</p><p>I added these new lines:</p><pre>#!/bin/sh<br>set -e<br><br># all the envsubst logic).....<br><br><br><br># 3. Delete the /dev/stdout symlink that the nginx:alpine base image uses<br>rm -f /var/log/nginx/access.log<br><br># 4. Create a new, REAL file for Nginx to write to<br>touch /var/log/nginx/access.log<br><br>echo &quot;Nginx config generated:&quot;<br>cat /etc/nginx/conf.d/default.conf<br>echo &quot;------------------------&quot;<br><br># 5. Start the Nginx server in the foreground.<br>#    This is the main command that keeps the container running.<br>echo &quot;Starting Nginx...&quot;<br>nginx -g &#39;daemon off;&#39;</pre><h4>Step 6: Create the Python watcher</h4><p>This is the brain of the setup. I created a new file called <strong>watcher.py</strong>. This script will:</p><ul><li>Load the environment variables.</li><li>Open /var/log/nginx/access.log and “seek” to the end.</li><li>Run in a while True: loop, reading new lines.</li><li>Parse the JSON and check for failovers or high error rates.</li><li>Send alerts.</li></ul><p>You can access the file <a href="https://github.com/cf-cloud89/nginx-blue-green-observability/blob/main/watcher.py">here</a> or fork the repo and get all the files at once.</p><h4>Step 7: Create the requirements.txt file</h4><p>This file tells Python what libraries it needs. This is the content:</p><pre>requests</pre><h4>Step 8: Create the runbook.md file</h4><p>An alert is useless if the operator doesn’t know what to do. A runbook is the “Action” plan. <a href="https://github.com/cf-cloud89/nginx-blue-green-observability/blob/main/runbook.md">This document</a> explains what to do when the operator receive an alert on Slack.</p><h3>How I Tested the Setup</h3><p>Here are the steps I followed:</p><h4>1. Make nginx-init.sh executable</h4><pre>chmod +x nginx-init.sh</pre><h4>2. Add the current user to the Docker group and start the entire stack</h4><pre>sudo usermod -aG docker $USER<br>docker compose up -d</pre><h4>3. Test 1: Failover &amp; Recovery Alert</h4><p><strong>Induce chaos:</strong></p><pre>curl -X POST http://[YOUR_SERVER_IP]:8081/chaos/start?mode=error</pre><p>Sent a request:</p><pre>curl http://[YOUR_SERVER_IP]:8080/version</pre><p>Then checked Slack and got a “FAILOVER DETECTED” alert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-_sPSGnJ1kKTgqVV3rrxA.jpeg" /></figure><p><strong>Stop chaos:</strong></p><pre>curl -X POST http://[YOUR\_SERVER\_IP]:8081/chaos/stop</pre><p>Waited 5–10 seconds and sent another request:</p><pre>curl http://[YOUR_SERVER_IP]:8080/version</pre><p>Then checked Slack and also got a “RECOVERY” alert.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eVSuVnGrXZcqAZBXFpREBg.jpeg" /></figure><h4>4. Test 2: High Error Rate Alert</h4><p><strong>Induce chaos again:</strong></p><pre>curl -X POST http://[YOUR_SERVER_IP]:8081/chaos/start?mode=error</pre><p>Ran a loop to send 250 requests (to fill the WINDOW_SIZE):</p><pre>for i in {1..250}; do curl -s -o /dev/null http://[YOUR_SERVER_IP]:8080/; done</pre><p>Then checked Slack and received the “High Error Rate” alert as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mU1NbHMfRtFyPi623kdMBw.jpeg" /></figure><p><strong>Note:</strong> This test worked because I set max_fails=200 in the Nginx config, which forced it to try the failing server every time.</p><h3>What I Learnt While Doing the Project</h3><p>Building this project wasn’t just a simple “follow the steps” task. I ran into several real-world “aha” moments that taught me more than writing the code itself. Here are some of them:</p><ul><li><strong>A “Silent Failover” is a Hidden Risk.</strong> The biggest conceptual takeaway was this: a high-availability system that fails <em>silently</em> is dangerous. It gives you a false sense of security. You <em>think</em> you’re safe, but you’re blind. Adding this alerting layer moves you from <em>hoping</em> your system is working to <em>knowing</em> how it’s behaving.</li><li><strong>Observability Doesn’t Have to Be Expensive.</strong> I didn’t need a massive, complex, and expensive ELK or Grafana/Loki stack to get powerful insights. The “sidecar” pattern — using a simple Docker volume (<em>nginx-logs</em>) as a high-speed communication bus between my Nginx container and a lightweight Python script — is an incredibly effective and low-cost solution.</li><li><strong>Docker Image Internals Can Be Confusing.</strong> My <em>watcher.py</em> script crashed at first with an <em>io.UnsupportedOperation: underlying stream is not seekable</em> error. This was confusing, but it helped me learn that the official <em>nginx:alpine</em> image, by default, doesn&#39;t log to a <em>real file</em>. It symlinks <em>/var/log/nginx/access.log</em> to a <em>/dev/stdout</em> stream. You can&#39;t &quot;tail&quot; or &quot;seek&quot; a stream. The fix was to use the <em>nginx-init.sh</em> script to manually <strong>rm</strong> that symlink and <strong>touch </strong>a <em>real</em> log file before Nginx starts.</li><li><strong>An Alert is Just Noise Without an Action.</strong> The final piece of the puzzle wasn’t the code; it was the <em>runbook.md</em>. An alert that says &quot;FAILOVER!&quot; just causes panic. An alert that says:<strong> &quot;FAILOVER DETECTED: Traffic has flipped to &#39;green&#39;. Action: Check <em>docker logs app_blue</em> to investigate&quot;</strong> turns that panic into a calm, direct, and immediate pointer to the solution.</li></ul><p>Did you learn something new from this piece? Tap the clap icon👏 multiple times and follow me for more DevOps content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f52cced60fa7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Day 31–35) 100 Days of DevOps Challenge by KodeKloud]]></title>
            <link>https://medium.com/@ChinecheremU/day-31-35-100-days-of-devops-challenge-by-kodekloud-c7c8cf0ac760?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7c8cf0ac760</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[kodekloud]]></category>
            <category><![CDATA[docker-compose]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Fri, 31 Oct 2025 11:14:04 GMT</pubDate>
            <atom:updated>2025-10-31T11:14:04.584Z</atom:updated>
            <content:encoded><![CDATA[<p>Days 31–34 of the <a href="https://kodekloud.com/100-days-of-devops"><strong>100 Days of DevOps Challenge by KodeKloud</strong></a> focused on advancing practical DevOps version control and containerization skills. The tasks explored essential Git operations such as <strong>stashing</strong>, <strong>rebasing</strong>, <strong>resolving merge conflicts</strong>, and using <strong>Git hooks</strong> to automate actions during repository events. Day 35 was a hands-on experience in <strong>installing Docker packages and starting the Docker service.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*SjaNkwCL-fA6qboF.png" /><figcaption>100 Days of DevOps with KodeKloud</figcaption></figure><h3>Day 31: Restore and Commit Stashed Changes in Git</h3><p>This task explains how to restore previously stashed changes in a Git repository. The goal of the task was to locate the stashed work under <strong>/usr/src/kodekloudrepos/games</strong>, apply the stash identified as <strong>stash@{1}</strong>, then commit and push the restored changes to the remote repository.</p><p>Here are the steps to follow to get it done:</p><h4>1. SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><p>Switch to the root user:</p><pre>sudo -i</pre><h4>2. Move into the repository</h4><pre>cd /usr/src/kodekloudrepos/games</pre><h4>3. Check available stashes</h4><pre>git stash list</pre><p>You should see one or more entries, including stash@{1} — the one you need to restore.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*H9MjBv-Wk2rhfEK_7b4kXQ.png" /></figure><h4>4. Apply the specific stash</h4><pre>git stash apply stash@{1}</pre><p>This restores the changes saved under that stash ID.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*Go5xERrouDNKDFnIyHl6uQ.png" /></figure><h4>5. Stage and commit the restored files</h4><pre>git add .<br>git commit -m &quot;Restored stash@{1} changes&quot;</pre><h4>6. Push the commit to the remote repository</h4><pre>git push</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*3DKmos3bCUGA3UE6vagF2Q.png" /></figure><p>The stashed changes from <strong>stash@{1}</strong> have been successfully restored, committed, and pushed to the remote repository.</p><h3><strong>Day 32:</strong> Git Rebase</h3><p>The Nautilus application development team has been working on a project repository located at <strong>/usr/src/kodekloudrepos/blog </strong>on the Storage Server in Stratos DC. One of the developers was working on the <strong>feature </strong>branch, while new updates had been pushed into the <strong>master </strong>branch. The task was to <strong>rebase </strong>the <strong>feature branch </strong>on the<strong> master branch</strong> so that it contains the latest updates without creating a merge commit.</p><p>Here’s how I completed the task:</p><h4>1. SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><p>Switch to the root user:</p><pre>sudo -i</pre><h4><strong>2. Navigate to the repository directory</strong></h4><pre>cd /usr/src/kodekloudrepos/blog</pre><h4><strong>3. Check the current branch</strong></h4><pre>git branch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*oQ96qzsjTirLRHnVR_Z3Sw.png" /></figure><p>This confirmed I was on the <strong>feature </strong>branch. Switch to the feature branch if not already on it:</p><pre>git checkout feature</pre><h4><strong>4. Rebase the feature branch with the master branch</strong></h4><pre>git rebase master</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/684/1*0WBk3jBKj_NiPfWANOr72w.png" /></figure><p>This applied the commits from the <strong>feature </strong>branch on top of the latest commits from the <strong>master</strong> branch, to avoid the creation of an unnecessary merge commit.</p><h4><strong>5. Verify the rebase</strong></h4><pre>git log --oneline --graph --decorate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*XLFtGBT0UlFakBEZ5tvHwQ.png" /></figure><p>This confirmed that the feature branch history was now based on the updated master branch.</p><h4><strong>6. Push the updated feature branch to the remote repository</strong></h4><p>Since a rebase rewrites commit history, I had to force push the branch:</p><pre>git push origin feature --force</pre><p>The task was completed — the <strong>feature </strong>branch was rebased onto the <strong>master </strong>branch, thereby preserving all its work without adding a merge commit.</p><h3>Day 33: Resolve Git Merge Conflicts</h3><p>In this task, sarah and max were collaborating on a repository called <strong>story-blog</strong>, located in <strong>/home/max</strong> on the Storage Server in Stratos DC. Both had been working on adding story titles, but when max tried to push his recent changes, he encountered merge conflicts. The goal was to fix the issues, ensure all four story titles appeared in the <em>story-index.txt</em> file, and correct the typo <strong>“Mooose” → “Mouse.”</strong></p><p>Here’s how I fixed the problem step by step:</p><h4><strong>1. SSH into the storage server as Max</strong></h4><pre>ssh max@ststor01<br># password: Max_pass123</pre><h4><strong>2. Navigate to the story-blog repository</strong></h4><pre>cd /home/max/story-blog</pre><h4><strong>3. Check the current branch and repository status</strong></h4><pre>git status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*v05kHS63Qt4KqDuhBGt9yg.png" /></figure><p>This showed that max had local changes not yet pushed, and the remote repository had new commits — a common cause of push errors.</p><h4><strong>4. Pull the latest changes from the remote repository</strong></h4><pre>git pull origin master</pre><p>During this step, Git displayed <strong>merge conflict warnings</strong> inside <strong>story-index.txt</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*k_39FczXVaZ33BOaj5ydvw.png" /></figure><h4><strong>5. Open the conflicted file</strong></h4><pre>vi story-index.txt</pre><p>The file contained conflict markers like this:</p><pre>&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD<br>1. The Lion and the Mooose<br>2. The Frogs and the Ox<br>3. The Fox and the Grapes<br>4. The Donkey and the Dog<br>=======<br>1. The Lion and the Mouse<br>2. The Frogs and the Ox<br>3. The Fox and the Grapes<br>&gt;&gt;&gt;&gt;&gt;&gt;&gt; 001e4722d79e5a5ed3a50fac7e5fd23f4ca54e06</pre><h4><strong>6. Manually resolve the conflicts</strong></h4><ul><li>Keep the correct titles for all <strong>four stories.</strong></li><li>Fix the typo: change <strong>Mooose → Mouse.</strong></li></ul><p>The final file should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*AH9HiSNjjU9CH2kLiyuztQ.png" /></figure><h4><strong>7. Mark the conflict as resolved and commit the changes</strong></h4><pre>git add story-index.txt <br>git commit -m &quot;Resolved merge conflicts and fixed typo in story titles&quot;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*U3HTrseBHEZoKYFmg0M1lQ.png" /></figure><h4><strong>8. Push the changes to the remote repository</strong></h4><pre>git push origin master</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*hTsG-R3xiKiTBdxnJwDRFg.png" /></figure><p>This time, the push succeeded without any error.</p><h4><strong>9. Verify changes in Gitea UI</strong></h4><p>Log in to the <strong>Gitea web interface</strong> using either of these credentials:</p><ul><li><strong>Username: </strong>sarah / max</li><li><strong>Password:</strong> Sarah_pass123 / Max_pass123</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qRXcDJuMDAWb2xiBM-OCXw.png" /></figure><p>The above screenshot confirmed that the <strong>story-index.txt</strong> file now displays all four story titles correctly.</p><h3>Day 34: Git Hook — Automate Release Tag Creation</h3><p>In this task, I worked on a Git repository stored on the Storage server in the Stratos DC. My goal was to merge a feature branch into the <strong>master</strong> branch and then configure a <strong>post-update</strong> hook that automatically creates a release tag every time new changes are pushed to master.</p><p>The tag format follows:</p><pre>release-YYYY-MM-DD</pre><p>So if today is <strong>October 31, 2025</strong>, the tag becomes:</p><pre>release-2025-09-29</pre><p>Let’s walk through the steps I followed to complete and verify this task.</p><h4>Step 1: SSH into the storage server</h4><p>I connected to the Storage server using <strong>natasha </strong>as the username:</p><pre>ssh natasha@ststor01</pre><h4>Step 2: Move into the repository</h4><p>The repository was already cloned under <strong>/usr/src/kodekloudrepos/cluster/</strong>, so I switched there:</p><pre>cd /usr/src/kodekloudrepos/cluster/<br>pwd<br>ls -la</pre><h4>Step 3: Check available branches</h4><p>I confirmed the <strong>feature</strong> and <strong>master</strong> branches existed:</p><pre>sudo git branch<br>sudo git branch -a</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*aukjLbTNl8QxRNvCcFE9rQ.png" /></figure><h4>Step 4: Merge feature into master</h4><p>I switched to the master branch, then merged:</p><pre>git checkout master<br>git merge feature</pre><p>Git fast-forwarded the merge, and I reviewed the commit history:</p><pre>sudo git log --oneline</pre><h4>Step 5: Create the post-update hook</h4><p>The bare repository lives at <strong>/opt/cluster.git</strong>. I opened the hook file:</p><pre>sudo vi /opt/cluster.git/hooks/post-update</pre><p>Then I added the script:</p><pre>#!/bin/sh<br>if [ &quot;$1&quot; = &quot;refs/heads/master&quot; ]; then<br>  echo &quot;Creating release tag&quot;<br>  git tag release-`date &#39;+%Y-%m-%d&#39;` master<br>fi</pre><p>This script checks if the push was made to <strong>master</strong>, and if yes, it automatically tags that commit with the current date.</p><h4>Step 6: Make the hook executable</h4><pre>sudo chmod +x /opt/cluster.git/hooks/post-update</pre><h4>Step 7: Push changes to trigger the hook</h4><pre>sudo git push origin master</pre><p>After pushing, the hook fired and created the release tag automatically.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*PLqnj7VbBFHx8sUz37KkaA.png" /></figure><h4>Step 8: Verify the tag</h4><p>I pulled the latest tags and confirmed the new release tag existed:</p><pre>sudo git fetch --all</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*ycPNljZ4PJv5tXi0gF_cxg.png" /></figure><pre>sudo git tag</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*xTqtWCqgFl5G8WAJOjsTnA.png" /></figure><p>I also checked the commit graph:</p><pre>git log --oneline --all --graph</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*Q8uXgakbjiGgJl1bL-VtRw.png" /></figure><p>The tag pointed to the latest commit on <strong>master</strong> — perfect.</p><h4>Why This Matters:</h4><p>Automating release tagging ensures consistency and reduces manual steps during deployments. This setup makes it easy to track when changes hit production — especially in environments where multiple team members push code daily.</p><h3>Day 35: Set Up Docker &amp; Docker Compose on App Server 1</h3><p>Today’s task was straightforward — install <strong>Docker CE</strong> and <strong>Docker Compose</strong>, then start the Docker service so the DevOps team can begin experimenting with containerized workloads.</p><p>Here are the steps I followed to complete the task:</p><h4>1. SSH into App Server 1 and switch to the root user</h4><pre>ssh tony@stapp01<br>sudo -i</pre><h4>2. Install Docker Community Edition</h4><p>First, I installed the required dependencies:</p><pre>sudo yum install -y yum-utils device-mapper-persistent-data lvm2</pre><p>Next, I added the Docker repository:</p><pre>sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo</pre><p>Then installed Docker CE:</p><pre>sudo yum install -y docker-ce docker-ce-cli containerd.io</pre><h4>3. Install Docker Compose</h4><pre>sudo curl -L &quot;https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)&quot; -o /usr/local/bin/docker-compose<br>sudo chmod +x /usr/local/bin/docker-compose</pre><p>To confirm installation, run:</p><pre>docker compose version<br>docker --version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/685/1*ClaqVRnT841n7LN2gIXasg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*qLQbpFNTDTipob7RRrEBKQ.png" /></figure><h4>4. Start and enable Docker service</h4><pre>sudo systemctl start docker<br>sudo systemctl enable docker</pre><p>Verify it was running:</p><pre>sudo systemctl status docker</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*BXQqpSlds0chI_vjZEbpjA.png" /></figure><h4>5. Test Docker functionality</h4><p>I ran a test container to verify Docker can pull images and run containers.</p><pre>docker run hello-world</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*jaO0wT0jCa6i5-2nmuzzTg.png" /></figure><p><strong>Result: </strong>The server is now ready to run containers and test the first application services in a Dockerized environment.</p><p>Check my page for Day 36 task!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7c8cf0ac760" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Configure NGINX as a Reverse Proxy on AWS EC2]]></title>
            <link>https://medium.com/@ChinecheremU/how-to-configure-nginx-as-a-reverse-proxy-on-aws-ec2-c06631b40cf9?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/c06631b40cf9</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[web-server]]></category>
            <category><![CDATA[flask]]></category>
            <category><![CDATA[nginx-reverse-proxy]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Wed, 29 Oct 2025 00:28:47 GMT</pubDate>
            <atom:updated>2025-10-29T00:28:47.682Z</atom:updated>
            <content:encoded><![CDATA[<p>Configuring NGINX as a reverse proxy is one of those key DevOps skills that bridges networking and application deployment. In this guide, I’ll walk you through how I set up <strong>NGINX on an AWS EC2 instance to route traffic between users and a Flask backend app running on port 5000</strong>. By the end, you’ll understand not just the “how,” but also the “why” behind using a reverse proxy in real-world deployments.</p><p>This task helped me understand one of NGINX’s most powerful roles beyond serving static files — acting as a traffic manager between users and backend applications.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yg1ZRlYpS_PtfmePskvAKw.png" /><figcaption>Image source: fity.club</figcaption></figure><h3>Firstly, What is a Reverse Proxy?</h3><p>When you deploy a web app, you often have two parts:</p><ul><li>A <strong>frontend</strong> (HTML, React, or Vue)</li><li>A <strong>backend</strong> (Node.js, Flask, or Django)</li></ul><p>Both usually run on different ports. For example</p><ul><li>Frontend → port 80</li><li>Backend → port 5000</li></ul><p>Without a reverse proxy, users would need to access different ports directly:</p><pre>Frontend → http://your-server-ip/<br>Backend → http://your-server-ip:5000/</pre><p>But that’s not ideal.<br>A <strong>reverse proxy</strong> like <strong>NGINX</strong> solves this by sitting <strong>in front</strong> of both parts, receiving all requests and forwarding some of them internally.</p><p>So instead of exposing multiple ports, users just visit:</p><pre>http://your-server-ip/</pre><p>and NGINX handles the routing behind the scenes.</p><h3>Why “Reverse” Proxy?</h3><p>In networking, a <strong>forward proxy</strong> hides the client from servers (used for things like web filtering).<br>A <strong>reverse proxy</strong>, on the other hand, hides the <strong>servers</strong> from clients.</p><p>It’s called “reverse” because it works in the opposite direction — sitting in front of servers to protect, route, and optimize traffic flow.</p><h3>Why Use NGINX as a Reverse Proxy?</h3><p>NGINX can:</p><ul><li>Hide backend servers and ports from users</li><li>Simplify URLs (no more :5000 or :3000)</li><li>Improve security by controlling what’s exposed</li><li>Handle HTTPS (SSL) termination</li><li>Load balance multiple backends</li><li>Cache and compress responses for speed</li></ul><p>In short, NGINX becomes the <strong>gateway</strong> between your users and your application.</p><h3>Step-by-Step Nginx Reverse Proxy Setup on AWS EC2</h3><h4>1. Environment Setup</h4><ul><li><strong>Platform:</strong> AWS EC2 (Amazon Linux)</li><li><strong>Web Server:</strong> NGINX</li><li><strong>Backend App:</strong> Simple Python Flask app on port 5000</li></ul><p>Your traffic flow will look like this:</p><pre>User → NGINX (port 80) → Flask app (port 5000)</pre><h4>2. Install Flask</h4><p>Launch an EC2 instance and SSH into it, then run:</p><pre>sudo dnf update -y  ---&gt; Updates existing packages<br>sudo dnf install python3 -y  ---&gt; Installs python3 and related packages<br>pip3 install flask  ---&gt; Installs flask</pre><h4>3. Create a Simple Backend App</h4><pre>vi ~/app.py</pre><p>Paste this code:</p><pre>from flask import Flask<br><br>app = Flask(__name__)<br><br>@app.route(&#39;/api&#39;)<br><br>def hello():<br>    return {&#39;message&#39;: &#39;Hello from Flask Backend&#39;}<br>if __name__ == &#39;__main__&#39;:<br>    app.run(host=&#39;0.0.0.0&#39;, port=5000)</pre><p>Save and exit.</p><p>Then start the app:</p><pre>python3 ~/app.py</pre><p>Test it locally:</p><pre>curl http://localhost:5000/api</pre><p>Expected output:</p><pre>{&quot;message&quot;: &quot;Hello from Flask Backend&quot;}</pre><h4>4. Configure NGINX as a Reverse Proxy</h4><p>Edit your NGINX configuration file:</p><pre>sudo vi /etc/nginx/nginx.conf</pre><p>Inside the <strong>server </strong>block, update it like this:</p><pre>server {<br>    listen 80;<br>    server_name _;<br><br>    location / {<br>        root   /usr/share/nginx/html;<br>        index  index.html;<br>    }<br>    location /api {<br>        proxy_pass http://127.0.0.1:5000;<br>        proxy_set_header Host $host;<br>        proxy_set_header X-Real-IP $remote_addr;<br>    }<br>}</pre><h4>Breakdown:</h4><ul><li><strong>proxy_pass</strong>— Forwards the request to the backend app (on port 5000).</li><li><strong>127.0.0.1</strong>— The loopback address for the same server (localhost).</li><li><strong>proxy_set_header Host $host; </strong>— Keeps the original hostname in the request headers.</li><li><strong>proxy_set_header X-Real-IP $remote_addr; </strong>— Passes the real client IP to the backend.</li></ul><h4>5. Test and Restart NGINX</h4><pre>sudo nginx -t<br>sudo systemctl restart nginx</pre><p>Check that the configuration test returns:</p><pre>nginx: configuration file /etc/nginx/nginx.conf test is successful</pre><h4>6. Test from Browser</h4><p>Visit:</p><pre>http://&lt;your-ec2-public-ip&gt;/api</pre><p>If everything works, you should see:</p><pre>{&quot;message&quot;: &quot;Hello from Flask Backend&quot;}</pre><p>Success! NGINX is now acting as a <strong>reverse proxy.</strong></p><h4>7. Optional: Serve a Frontend Too</h4><p>If you also have static files (like an <strong>index.html</strong>), NGINX will:</p><ul><li>Serve <strong>/ </strong>→ from <strong>/usr/share/nginx/html</strong></li><li>Proxy <strong>/api </strong>→ to your Flask app</li></ul><p>Both use <strong>port 80</strong>, so users interact with a single public endpoint.</p><p><strong>Note: </strong>Always use <em>sudo nginx -t </em>to verify syntax before restarting the server.</p><h3>What I Learned</h3><ol><li><strong>Conceptually:</strong><br>A reverse proxy sits in front of backend servers, forwarding requests and hiding internal architecture from users.</li><li><strong>Technically:</strong><br>NGINX’s proxy_pass directive enables backend routing, while proxy_set_header preserves real user and host data.</li><li><strong>Practically:</strong><br>I can now unify frontend and backend access under one domain or IP without exposing multiple ports.</li></ol><h3>Conclusion</h3><p>Configuring NGINX as a reverse proxy gave me a deeper understanding of how web traffic flows in production environments. It’s a fundamental skill for any DevOps engineer — and an essential step toward mastering server management and scalable web architecture.</p><p><strong>I’m glad you read till the end! </strong>If you learned something from the article, tap the clap icon👏 multiple times and follow me for more DevOps content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c06631b40cf9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a Production-Ready Deployment Bash Script for Dockerized Applications]]></title>
            <link>https://medium.com/@ChinecheremU/how-i-built-a-production-ready-deployment-script-for-dockerized-applications-7620f691380d?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/7620f691380d</guid>
            <category><![CDATA[bash-script]]></category>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 23:38:15 GMT</pubDate>
            <atom:updated>2025-10-28T23:43:04.618Z</atom:updated>
            <content:encoded><![CDATA[<p>In modern DevOps practices, deployment automation helps to maintain consistency, reduce human error, and accelerate application release cycles.</p><p>Recently, at the HNG internship program, I was given a task to <strong><em>develop a robust, production-grade Bash script that automates the setup, deployment, and configuration of a Dockerized application on a remote Linux server.</em></strong></p><p>In this article, I will walk you through how I worked on the project and wrote a comprehensive Bash script that automates the entire deployment pipeline for Dockerized applications — from repository cloning to production readiness.</p><p>You might ask,</p><h3>Why an Automated Deployment Bash Script?</h3><p>Manual application deployment processes are usually time-consuming and error-prone. The typical workflow involves:</p><ul><li>SSH-ing into servers</li><li>Cloning repositories</li><li>Installing dependencies</li><li>Building Docker images</li><li>Configuring reverse proxies</li><li>Managing port conflicts</li><li>Testing deployments</li></ul><p>Doing this manually for every deployment wastes valuable time and introduces inconsistencies across environments.</p><p>For that reason, building a production-grade Bash script that automates the complete deployment workflow for Dockerized applications on remote Linux servers becomes necessary. The script handles everything from environment setup to validation, with comprehensive error handling and logging throughout.</p><h3>The Bash Script’s Key Features and Structure/Workflow</h3><h4>Features</h4><p><strong>1. Universal Compatibility</strong></p><ul><li>Supports both Ubuntu/Debian (apt) and RHEL/CentOS/Fedora (dnf)</li><li>Auto-detects the package manager on the remote server</li><li>Works with any Dockerized application</li></ul><p><strong>2. Intelligent Deployment</strong></p><ul><li>Supports both Dockerfile and docker-compose.yml</li><li>Automatic port conflict resolution</li><li>Idempotent design (safe to run multiple times)</li><li>Rolling updates with zero-downtime capability</li></ul><p><strong>3. Enterprise-Grade Features</strong></p><ul><li>Comprehensive input validation</li><li>Timestamped logging for audit trails</li><li>Automatic Nginx reverse proxy configuration</li><li>Health checks and endpoint validation</li><li>Cleanup mode for resource management</li></ul><p><strong>4. Developer-Friendly</strong></p><ul><li>Interactive prompts with sensible defaults</li><li>Clear error messages and warnings</li><li>Detailed deployment summaries</li><li>Fallback mechanisms (rsync → scp)</li></ul><h4>Structure/Workflow</h4><p>The script follows a modular architecture with clear separation of concerns:</p><pre>┌─────────────────────────────────────┐<br>│     User Input Collection           │<br>│  (Validation &amp; Authentication)      │<br>└──────────────┬──────────────────────┘<br>               ↓<br>┌─────────────────────────────────────┐<br>│    Repository Operations            │<br>│  (Clone/Update with PAT Auth)       │<br>└──────────────┬──────────────────────┘<br>               ↓<br>┌─────────────────────────────────────┐<br>│    Remote Environment Setup         │<br>│ (Docker, Compose, Nginx Install)    │<br>└──────────────┬──────────────────────┘<br>               ↓<br>┌─────────────────────────────────────┐<br>│    Application Deployment           │<br>│  (Build, Run, Port Management)      │<br>└──────────────┬──────────────────────┘<br>               ↓<br>┌─────────────────────────────────────┐<br>│    Nginx Configuration              │<br>│    (Reverse Proxy Setup)            │<br>└──────────────┬──────────────────────┘<br>               ↓<br>┌─────────────────────────────────────┐<br>│    Validation &amp; Testing             │<br>│   (Health Checks &amp; Reporting)       │<br>└─────────────────────────────────────┘</pre><h3>The Bash Script’s Core Components</h3><h4>1. Input Validation System</h4><p>Every user input is validated before proceeding:</p><ul><li><strong>Git URLs:</strong> Regex validation for HTTPS and SSH formats</li><li><strong>IP Addresses:</strong> Pattern matching for valid IPv4</li><li><strong>Ports:</strong> Range validation (1–65535)</li><li><strong>SSH Keys:</strong> File existence and permission checks (600/400)</li></ul><pre>validate_port() {<br>    local port=$1<br>    if ! [[ &quot;$port&quot; =~ ^[0-9]+$ ]] || [ &quot;$port&quot; -lt 1 ] || [ &quot;$port&quot; -gt 65535 ]; then<br>        log_error &quot;Invalid port number. Must be between 1-65535&quot;<br>        return 1<br>    fi<br>    return 0<br>}</pre><h4>2. OS Detection &amp; Package Management</h4><p>The script automatically detects the remote operating system and uses the appropriate package manager:</p><pre>determine_remote_os() {<br>    local os_type=$(execute_remote_command &quot;<br>        if command -v apt &amp;&gt; /dev/null; then <br>            echo &#39;APT&#39;<br>        elif command -v dnf &amp;&gt; /dev/null; then <br>            echo &#39;DNF&#39;<br>        fi<br>    &quot;)<br>    # Sets REMOTE_PKG_MANAGER accordingly<br>}</pre><h4>3. Intelligent File Transfer</h4><p>Prioritizes <strong>rsync</strong> for efficiency but gracefully falls back to scp+tar if unavailable:</p><pre>if command -v rsync &amp;&gt; /dev/null; then<br>    # Fast, incremental transfer with rsync<br>    rsync -avz --exclude=&#39;.git&#39; ...<br>else<br>    # Fallback: create tarball and use scp<br>    tar -czf /tmp/deploy.tar.gz .<br>    scp /tmp/deploy.tar.gz ...<br>fi</pre><h4>4. Port Conflict Resolution</h4><p>Before deploying, the script identifies and stops containers using the target port:</p><pre>CONTAINERS_ON_PORT=$(docker ps --filter publish=${APP_PORT})<br>if [ -n &quot;$CONTAINERS_ON_PORT&quot; ]; then<br>    echo &quot;$CONTAINERS_ON_PORT&quot; | xargs docker stop<br>    echo &quot;$CONTAINERS_ON_PORT&quot; | xargs docker rm<br>fi</pre><h4>5. Nginx Reverse Proxy Automation</h4><p>Dynamically generates Nginx configuration with optimal proxy settings:</p><pre>server {<br>    listen 80;<br>    server_name _;<br>    <br>    location / {<br>        proxy_pass http://localhost:${APP_PORT};<br>        proxy_http_version 1.1;<br>        proxy_set_header Upgrade $http_upgrade;<br>        proxy_set_header Connection &#39;upgrade&#39;;<br>        proxy_set_header Host $host;<br>        # Additional headers for proper proxying<br>    }<br>}</pre><h3>A Breakdown of How I Tested the Script</h3><p>To test the script, I used it to deploy a simple Flask app. Below is the application’s directory structure:</p><pre>Dockerized-App-Deployment-Script/<br>├── Dockerfile<br>├── requirements.txt<br>├── deploy.sh<br>└── server.py</pre><p><strong>Dockerfile:</strong></p><pre>FROM python:3.11-slim<br>WORKDIR /app<br>COPY . /app<br>RUN pip install flask<br>EXPOSE 5000<br>CMD [&quot;python&quot;, &quot;server.py&quot;]</pre><p><strong>Application Code (server.py):</strong></p><pre>from flask import Flask, jsonify<br>app = Flask(__name__)<br><br>@app.route(&quot;/api&quot;)<br>def api():<br>    return jsonify({&quot;message&quot;: &quot;Hello from Chinecherem Udegbunam&quot;})<br><br>@app.route(&quot;/&quot;)<br>def root():<br>    return &quot;&lt;h1&gt;Index served from container&lt;/h1&gt;&lt;p&gt;Try GET /api&lt;/p&gt;&quot;<br><br>if __name__ == &quot;__main__&quot;:<br>    app.run(host=&quot;0.0.0.0&quot;, port=5000)</pre><h3>The App Deployment Process</h3><h4>1. Move into the directory</h4><pre>cd Dockerized-App-Deployment-Script</pre><h4>2. Make the script executable</h4><pre>chmod +x deploy.sh</pre><h4><strong>3. Run the script</strong></h4><pre>./deploy.sh</pre><h4><strong>4. Provide inputs</strong></h4><pre>Enter Git Repository URL: <br>Enter Personal Access Token (PAT): <br>Enter branch name [main]: <br>Enter SSH username: <br>Enter server IP address: <br>Enter SSH key path [~/.ssh/id_rsa]: <br>Enter application port: </pre><h4><strong>5. Watch the magic happen</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/978/1*3jA8Z4MJ_t7xmwvLtIRoSA.png" /></figure><h4><strong>6. Access your application</strong></h4><pre>curl http://35.157.40.29/api</pre><p>The above command will output: <em>{“message”: “Hello from Chinecherem Udegbunam”}</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BXAYf74cn0OPxh4ufFhJqQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6eDmSr5t0iECKFDiDu1Pg.png" /></figure><p><strong>Note: </strong>Change the IP address to your server’s IP address. The output message you receive also depends on what you configured in your application code.</p><h3>To clean up after testing or deployment, run:</h3><pre>./deploy.sh --cleanup</pre><p>The command will trigger a cleanup process that stops and removes all the containers initially deployed on the remote server. It will also clean up the local temporary files.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/984/1*L-hqRTGp-d7nqQQf0RjBVA.png" /></figure><h3>What I Learned</h3><h4>1. Container naming convention</h4><p>Docker requires lowercase image/container names, so I implemented automatic name sanitization in the script:</p><pre>REPO_NAME=$(basename &quot;$GIT_REPO_URL&quot; .git | <br>    tr &#39;[:upper:]&#39; &#39;[:lower:]&#39; | <br>    tr -cd &#39;[:alnum:]-&#39;)</pre><h4>2. Port conflict management</h4><p>Re-deployments fail if old containers still occupy the port, so I set the script to proactively detect and stop conflicting containers before a new deployment.</p><h4>3. Error handling is critical</h4><p>Silent failures lead to debugging nightmares. I set comprehensive logging, meaningful exit codes, and trap handlers in the script for graceful cleanup.</p><h3>Conclusion</h3><p>This project demonstrates that powerful automation doesn’t require complex tools or frameworks. With solid Bash scripting knowledge and understanding of core DevOps concepts, you can build a production-ready deployment bash script that’s reliable, maintainable, and efficient.</p><p>If you want to test the script yourself, the complete code is available on my GitHub: <a href="https://github.com/cf-cloud89/Dockerized-App-Deployment-Script">github.com/cf-cloud89/Dockerized-App-Deployment-Script</a></p><p>Did you learn something new? Tap the clap icon👏 multiple times and follow me for more DevOps content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7620f691380d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Set Up a Resilient Blue/Green Deployment with Docker Compose and Nginx]]></title>
            <link>https://medium.com/@ChinecheremU/how-i-set-up-a-resilient-blue-green-deployment-with-docker-compose-and-nginx-9726a9a068bf?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/9726a9a068bf</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <category><![CDATA[nginx-reverse-proxy]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Tue, 28 Oct 2025 22:03:32 GMT</pubDate>
            <atom:updated>2025-10-28T22:17:40.467Z</atom:updated>
            <content:encoded><![CDATA[<p>As a DevOps Engineer, I’m fascinated by high availability. The concept of zero-downtime deployment is a core requirement for modern applications.</p><p>Recently, at the HNG internship, I was tasked with a project that put this to the test: <strong>build a smart Nginx reverse proxy</strong> to manage a Blue/Green application setup<em>.</em></p><p>Firstly, let’s understand what a Blue/Green deployment is.</p><h3>What is Blue/Green Deployment?</h3><p>Blue/Green deployment is a release strategy designed to achieve <strong>zero downtime</strong> and <strong>instant rollbacks</strong>. It’s one of the most effective ways to reduce the risk of deploying new software.</p><p>The concept is straightforward: you maintain two identical, parallel production environments, which we refer to as “Blue” and “Green.”</p><ul><li><strong>The Blue Environment:</strong> This is the <em>current, live</em> version of your application. It’s the one serving 100% of your user traffic.</li><li><strong>The Green Environment:</strong> This is an <em>identical, idle</em> environment. It’s the “standby” or “next” version.</li></ul><p>The deployment process works in three simple steps:</p><ol><li><strong>Step 1: Deploy.</strong> You deploy your new version of the code (e.g., v2.0) to the <strong>Green</strong> environment.</li><li><strong>Step 2: Test.</strong> While the Blue environment is still handling all live traffic, you can run a full suite of tests on the Green environment. It’s completely isolated, so you can’t break anything for real users.</li><li><strong>Step 3: The Switch.</strong> Once you’re 100% confident that the Green environment is stable, you “flip a switch” (usually a router or a proxy, like our Nginx). This switch instantly redirects all <em>new</em> user traffic from Blue to Green.</li></ol><p><strong>The Result:</strong> Green is now the new Blue (the live version), and your users never experienced a single second of downtime.</p><p><strong>The Safety Net:</strong> The old Blue environment is kept on standby. If you suddenly discover a critical bug in your new release, you don’t panic. You flip the switch right back to the old, stable Blue environment. This is known as <strong>instant rollback.</strong></p><p>This is exactly what we set out to build: an Nginx proxy that could act as that intelligent “switch.”</p><p>Before writing a single line of code, I had to first understand the <em>why</em>. The goal wasn’t just to route traffic; the system needed to be:</p><ol><li><strong>Manually controllable:</strong> I needed a “switch” to manually toggle 100% of traffic between the Blue and Green pools.</li><li><strong>Automatically resilient:</strong> If the primary pool (e.g., Blue) failed, the proxy <em>must</em> invisibly retry the request on the backup pool (Green) without the user ever seeing an error.</li><li><strong>Self-healing:</strong> When the failed pool recovers, the proxy should automatically detect this and route traffic back to it.</li></ol><h4>However, I had a little challenge.</h4><blockquote>Nginx configuration is famously static, but my requirements were purely dynamic.</blockquote><p>But here’s what I did.</p><p>I asked myself, “How do you tell Nginx which server is primary and which is backup just by changing an environment variable?”</p><p>I needed my <strong>nginx.conf </strong>file’s <strong>upstream </strong>block to look like this if <strong>ACTIVE_POOL=blue</strong>:</p><pre>upstream my_app {<br>    server app_blue:3000   max_fails=1 fail_timeout=10s;<br>    server app_green:3000 backup max_fails=1 fail_timeout=10s;<br>}</pre><p>But like this if ACTIVE_POOL=green:</p><pre>upstream my_app {<br>    server app_blue:3000  backup max_fails=1 fail_timeout=10s;<br>    server app_green:3000 max_fails=1 fail_timeout=10s;<br>}</pre><p>The answer was to stop thinking of the nginx.conf as a static file. Instead, I treated it as a <strong>template</strong>.</p><h4>What I Did</h4><p>I used a simple shell script as the Nginx container’s entrypoint. This script’s job is to read an environment variable and <em>generate</em> the final nginx.conf file <em>before</em> Nginx itself starts.</p><h3>The Directory Setup</h3><p>Below is a simple directory structure for the project:</p><pre>blue-green-deployment-with-nginx/<br>├── .env.example<br>├── README.md<br>├── docker-compose.yml<br>├── nginx-init.sh<br>├── nginx.conf.template<br>└── test-script</pre><p>Here are the four key files I used:</p><h4>1. docker-compose.yml</h4><p>This file tells the nginx service <em>not</em> to run its default command, but to run the script instead.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZUUkBDCm08R_ONfPQAkeA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ivPLt68OlhImNThcN2yqiQ.png" /></figure><h4>2. nginx.conf.template</h4><p>This is a standard Nginx config, but with variables for our script to replace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLmdKmIzXXa-k5vxWqCVJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qSMAuMSznTPQbyOIidi9gg.png" /></figure><h4>3. nginx-init.sh</h4><p>This script is the brain of the setup. It reads ACTIVE_POOL, exports the <strong>BLUE_STATUS </strong>and <strong>GREEN_STATUS </strong>variables, and then uses <strong>envsubst </strong>to generate the final config.</p><pre>#!/bin/sh<br><br># Exit immediately if a command exits with a non-zero status.<br>set -e<br><br># Install gettext-utils, which provides the &#39;envsubst&#39; command<br>apk add --no-cache gettext<br><br>echo &quot;Starting Nginx&#39;s nginx-init script...&quot;<br>echo &quot;Active pool is: $ACTIVE_POOL&quot;<br><br># 1. Logic to set status variables based on ACTIVE_POOL<br>if [ &quot;$ACTIVE_POOL&quot; = &quot;green&quot; ]; then<br>    echo &quot;Setting GREEN as primary, BLUE as backup.&quot;<br>    export BLUE_STATUS=&quot;backup&quot;<br>    export GREEN_STATUS=&quot;&quot;<br>else<br>    echo &quot;Setting BLUE as primary, GREEN as backup.&quot;<br>    export BLUE_STATUS=&quot;&quot;<br>    export GREEN_STATUS=&quot;backup&quot;<br>fi<br><br># 2. Use envsubst to substitute variables in the template<br>#    and create the final config file for Nginx to use.<br>envsubst &#39;$PORT $BLUE_STATUS $GREEN_STATUS&#39; &lt; /etc/nginx/templates/default.conf.template &gt; /etc/nginx/conf.d/default.conf<br><br>echo &quot;Nginx config generated:&quot;<br>cat /etc/nginx/conf.d/default.conf<br>echo &quot;------------------------&quot;<br><br># 3. Start the Nginx server in the foreground.<br>#    This is the main command that keeps the container running.<br>echo &quot;Starting Nginx...&quot;<br>nginx -g &#39;daemon off;&#39;</pre><h4>4. .env.example</h4><p>This file contains the environment variables the setup needs — such as the BLUE_IMAGE and GREEN_IMAGE (app_blue and app_green Docker images), the app’s PORT, ACTIVE_POOL, and the app Release IDs.</p><h3>How I Did the Setup Live Testing</h3><p>With the implementation complete (and a few bugs ironed out), it was time to test all four requirements.</p><p>Firstly, I tested the IP address bound to <em>app_blue</em>’s port on my browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wIQrjwuheRYsnnYY9h9FLw.png" /></figure><p>With my configuration files (docker-compose.yml, nginx-init.sh, nginx.conf.template, .env.example) all in place, it was time to bring the system to life. This is where Docker Compose<strong> </strong>shows its power.</p><p>I ran the one-shot command from my server’s terminal:</p><pre>docker compose up -d</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E7P4DEF_OMm1iCtLg1lQ3A.png" /></figure><p>This single command kicked off a fully automated process:</p><ul><li>First, it read my <strong>docker-compose.yml </strong>file to understand the services.</li><li>It then <strong>pulled</strong> all the necessary images (the nginx:1.25.3-alpine image and the two application images) from their respective registries.</li><li>Finally, it <strong>deployed</strong> all three containers ( <strong>app_blue</strong>, <strong>app_green, </strong>and <strong>nginx_proxy</strong>) in the background and connected them all to the same internal network.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uHssKnbDriCNmmQv_kNzfQ.png" /></figure><p>The app containers started up, but the nginx_proxy container followed its special instructions. It executed the nginx-init.sh script, which instantly generated the correct nginx.conf file based on the ACTIVE_POOL=blue variable, and <em>then</em> started the Nginx process. The whole system was now live and ready for its first test.</p><p>Then, I ran these commands from my local terminal against my EC2 instance’s IP address.</p><p>Note: Change <strong>[SERVER_IP] to your virtual server’s IP address.</strong></p><h4>Test 1: Baseline (Blue Active)</h4><pre>curl -i http://[SERVER_IP]:8080/version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J4RZx7TkwPzbh9wPwqFGiQ.png" /></figure><p>Result: 200 OK! The headers showed it was correctly routing traffic to the primary pool, which is blue.</p><h4>Test 2: Auto-Failover (Blue →Green)</h4><p>Next, I simulated a failure in the Blue app by hitting its chaos endpoint.</p><pre>curl -X POST http://[SERVER_IP]:8081/chaos/start?mode=error</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sthqxx-Jp21qpe-RtLZExw.png" /></figure><p>Then tested again.</p><pre>curl -i http://[SERVER_IP]:8080/version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90UuGgOzHidfzah39_Gj0Q.png" /></figure><p>Result: A perfect, invisible failover! I still got a 200 OK, but the headers proved the request was served by the backup Green pool. The user would never know Blue had failed.</p><h4>Test 3: Auto-Recovery (Green → Blue)</h4><p>Now, to test the self-healing. I told the Blue app to become healthy again by s<strong>topping the chaos on it.</strong></p><pre>curl -X POST http://[SERVER_IP]:8081/chaos/stop</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e8hTMel1agv-qKUo5GE_vA.png" /></figure><p>After waiting 10–15 seconds (for Nginx’s <strong>fail_timeout </strong>to expire), I tested the proxy again.</p><pre>curl -i http://[SERVER_IP]:8080/version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c57PbyqUE45GxbhipwSVwQ.png" /></figure><p><strong>Result:</strong> It worked! Nginx detected that Blue was healthy again and automatically routed traffic back to the primary pool.</p><h4>Test 4: Manual Toggle (Blue → Green)</h4><p>Finally, the manual switch. On the server, I edited my .env file to ACTIVE_POOL=green and restarted the Nginx container.</p><pre>vi .env  # Change ACTIVE_POOL=blue to ACTIVE_POOL=green<br>docker compose up -d --force-recreate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CwLr5QO4jr1YSDEt-jS1qA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lgMyiGMb-eJPgytMb8NpPA.png" /></figure><p><strong>Then tested the proxy again:</strong></p><pre>curl -i http://[SERVER_IP]:8080/version</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*90UuGgOzHidfzah39_Gj0Q.png" /></figure><p><strong>Result:</strong> 200 OK! The nginx-init.sh script read the new variable, generated a new config, and Green was now the primary pool.</p><h3>Final Words</h3><p>This project was a fantastic deep dive into building truly resilient systems. The combination of Docker Compose, an environment variables file, an nginx configuration template, and a simple shell script, gave Nginx the dynamic power it needed to be an intelligent proxy.</p><p>Working on this zero-downtime Blue/Green deployment task showed me:</p><ul><li>Various strategies for testing resilient systems.</li><li>How failovers work under the hood.</li><li>The importance of configuring your timeout properly.</li><li>How to containerize and orchestrate services using Docker Compose.</li></ul><p>If you want to try this task yourself, all the code is available on my GitHub: <a href="https://github.com/cf-cloud89/blue-green-deployment-with-nginx">github.com/cf-cloud89/blue-green-deployment-with-nginx</a></p><p><strong>Glad you made it to the end!</strong> If you learned something new, tap that clap icon👏 multiple times and follow me for more DevOps content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9726a9a068bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying an NGINX Web Server on an AWS EC2 Instance]]></title>
            <link>https://medium.com/@ChinecheremU/deploying-an-nginx-web-server-on-an-aws-ec2-instance-24758059373d?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/24758059373d</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[hnginternship]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Mon, 20 Oct 2025 00:45:13 GMT</pubDate>
            <atom:updated>2025-10-20T10:30:27.929Z</atom:updated>
            <content:encoded><![CDATA[<p>Setting up and deploying a web server from scratch is one of the first practical steps every DevOps engineer must learn. For my <strong>HNG DevOps Stage 0 project</strong>, the goal was simple — deploy an <strong>NGINX web server</strong> on a cloud instance, serve a custom HTML page, and make it publicly accessible via HTTP (port 80).</p><p>In this guide, I’ll walk through how I completed this task from start to finish.</p><h3>Project Overview</h3><p><strong>Project:</strong> NGINX Web Server for DevOps Stage 0 — serves a custom <strong>index.html </strong>at /usr/share/nginx/html/index.html.</p><h4><strong>Requirements:</strong></h4><ol><li>Deploy an EC2 instance on any cloud platform (AWS in my case).</li></ol><p>2. Install and configure NGINX to run on <strong>port 80</strong>.</p><p>3. Replace the default index.html with a custom one containing:</p><ul><li>My name</li><li>My Slack username</li><li>Deployment platform</li><li>Deployment date</li></ul><p>4. Ensure the site is publicly accessible at: http://&lt;server-ip&gt;/</p><h3>Step 1: Fork and Set Up the GitHub Repository</h3><p>a. Fork the repo <strong>hng13-stage0-devops</strong> on GitHub.</p><p>b. In your fork, create a <strong>README.md</strong> file containing:</p><ul><li>Your name</li><li>Your Slack username</li><li>A short project description</li><li>Your server IP (added after deployment)</li></ul><h3>Step 2: Create and Configure an AWS EC2 Instance</h3><p>a. Log in to your AWS Console.</p><p>b. Go to <strong>EC2 → Launch Instance</strong>.</p><p>c. Choose <strong>Amazon Linux 2023 AMI</strong>.</p><p>d. Select <strong>t2.micro</strong> (Free Tier eligible).</p><p>e. Create or select a <strong>key pair (.pem)</strong> — you’ll need it to SSH into the instance.</p><p>f. Configure your <strong>Security Group</strong> to allow:</p><ul><li><strong>Port 22 (SSH)</strong> — source: your IP only</li><li><strong>Port 80 (HTTP)</strong> — source: anywhere (0.0.0.0/0)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tjkjr2Jb2Qe4GEROOiLReA.png" /><figcaption>A screenshot of the EC2 instance in the running state</figcaption></figure><h4>(Optional) Assign an Elastic IP</h4><p>By default, AWS gives each instance a <strong>public IP that changes</strong> when restarted. In case you plan to restart the EC2 instance later, or want a permanent IP, allocate and associate an <strong>Elastic IP</strong>. Otherwise, the regular public IP works fine for temporary projects like this one.</p><h3>Step 3: Connect to the EC2 Instance via SSH</h3><pre>ssh -i ~/.ssh/hng13-stage0-devops.pem ec2-user@&lt;your-ec2-public-ip&gt;</pre><p><strong>Note: </strong>Your .pem key directory path should be where you saved your key pair. Once connected, you should see the Amazon Linux welcome message.</p><h3>Step 4: Install and Start NGINX</h3><p>Run:</p><pre>sudo yum update -y<br>sudo yum install nginx -y<br>sudo systemctl enable nginx<br>sudo systemctl start nginx</pre><p>Verify NGINX is running:</p><pre>sudo systemctl status nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-4AQptFyhrXmm6D4jwNY7w.png" /></figure><h3>Step 5: Create and Deploy Your Custom index.html</h3><p>The default NGINX root directory on Amazon Linux is <strong>/usr/share/nginx/html</strong>.</p><p>Replace the default index.html:</p><pre>sudo vi /usr/share/nginx/html/index.html</pre><p>Paste the following (replace with your details and your date of deployment):</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>  &lt;meta charset=&quot;UTF-8&quot;&gt;<br>  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>  &lt;title&gt;HNG13 DevOps Stage 0&lt;/title&gt;<br>  &lt;style&gt;<br>    body {<br>      font-family: Arial, sans-serif;<br>      display: flex;<br>      justify-content: center;<br>      align-items: center;<br>      height: 100vh;<br>      margin: 0;<br>      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);<br>      color: white;<br>    }<br>    .container {<br>      text-align: center;<br>      padding: 2rem;<br>      background: rgba(255, 255, 255, 0.1);<br>      border-radius: 10px;<br>      backdrop-filter: blur(10px);<br>    }<br>    h1 { margin-bottom: 1rem; }<br>    .timestamp { font-size: 0.9em; opacity: 0.8; }<br>  &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>  &lt;div class=&quot;container&quot;&gt;<br>    &lt;h1&gt;Welcome to DevOps Stage 0 - Chinecherem Udegbunam@NecheU&lt;/h1&gt;<br>    &lt;p&gt;Successfully deployed on an AWS EC2 instance&lt;/p&gt;<br>    &lt;p class=&quot;timestamp&quot;&gt;Deployed: 16/10/2025&lt;/p&gt;<br>  &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Save and exit, then restart NGINX:</p><pre>sudo systemctl restart nginx</pre><p>Test and verify that the nginx server is live (change the IP address to that of your web server):</p><pre>curl http://44.204.6.202</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tAKJHk0SvT9ZJ39Ug2acQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BtciuFweBDAI8g9nmSfAdw.png" /></figure><p>Now, open your browser and paste the command below:</p><pre>http://&lt;your-ec2-public-ip&gt;/</pre><p>You should see your custom message live.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tq42-a3n-nVCQQ3weuigPA.png" /></figure><h3>Step 6: Update Your GitHub README</h3><p>After confirming your site works, update the <strong>README.md </strong>file with your public IP address.<br>Then commit and push the changes:</p><pre>git add README.md<br>git commit -m &quot;Added project info and server IP&quot;<br>git push origin main</pre><h3>Recommendations</h3><ol><li><strong>Use Elastic IPs</strong> for persistent projects and production-level web server deployments when necessary. They ensure your server IP doesn’t change after reboot.</li><li><strong>Restrict SSH access</strong> to your own IP for security.</li><li>Keep your <strong>.pem </strong>files safe.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=24758059373d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Day 26–30) 100 Days of DevOps Challenge by KodeKloud]]></title>
            <link>https://medium.com/@ChinecheremU/day-26-30-100-days-of-devops-challenge-by-kodekloud-3798cbbe15cb?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/3798cbbe15cb</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[gitops]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Tue, 14 Oct 2025 13:09:34 GMT</pubDate>
            <atom:updated>2025-10-14T13:09:34.558Z</atom:updated>
            <content:encoded><![CDATA[<p>Days 26–30 of the <a href="https://kodekloud.com/100-days-of-devops"><strong>100 Days of DevOps Challenge by KodeKloud</strong></a> continued the in-depth exploration of Git. The tasks focused on more advanced version-control operations, including managing remotes, reverting changes, cherry-picking commits, handling pull requests, and performing hard resets.</p><p>This phase of the challenge mirrors scenarios that DevOps engineers regularly face in collaborative environments — fixing mistakes without disrupting the main branch, integrating specific changes across branches, and maintaining clean and synchronized repositories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*XsriBRWKMZVoGBEd.png" /><figcaption>100 Days of DevOps with KodeKloud</figcaption></figure><h3>Day 26: Set and Manage Remotes With Git</h3><p>In this task, we worked with an existing Git repository cloned at <em>/usr/src/kodekloudrepos/apps </em>on the s<strong>torage server</strong>.<br>The goal was to:</p><ul><li>Add a new remote named <strong>dev_apps </strong>pointing to <strong>/opt/xfusioncorp_apps.git</strong>.</li><li>Copy an <strong>index.html </strong>file from <strong>/tmp </strong>into the repository.</li><li>Commit the file to the <strong>master </strong>branch.</li><li>Push the master branch to the new remote.</li></ul><p>Here are the steps:</p><h4>1. SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><h4>2. Change to the repository directory</h4><pre>sudo cd /usr/src/kodekloudrepos/apps</pre><h4>3. Add the new remote</h4><pre>sudo git remote add dev_apps /opt/xfusioncorp_apps.git</pre><p>Check it:</p><pre>sudo git remote -v</pre><p>You should see <strong>dev_apps </strong>pointing to <strong>/opt/xfusioncorp_apps.git</strong>.</p><h4>4. Copy the file into the repository</h4><pre>sudo cp /tmp/index.html .</pre><h4>5. Stage and commit the file</h4><pre>sudo git add index.html<br>sudo git commit -m &quot;Add index.html file&quot;</pre><h4>6. Push master to the new remote</h4><pre>sudo git push dev_apps master</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*t92XofrBt0V4D9JyGqRZyw.png" /></figure><h4>7. Verify the Push</h4><pre>sudo git ls-remote --heads dev_apps</pre><p>You should see <strong>refs/heads/master </strong>listed on the new remote.</p><p>This task demonstrates how DevOps engineers often need to update repository remotes and synchronize changes across different Git servers.</p><h3>Day 27: Revert the Latest Commit in a Git Repository</h3><p>This guide explains how to safely revert the latest commit (<strong>HEAD</strong>) in the Git repository located at <strong>/usr/src/kodekloudrepos/official</strong> on the Storage server in Stratos DC. You’ll learn how to undo the most recent commit and make a new commit.</p><p>Here are the steps to follow:</p><h4>1. SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><h4>2. Go to the repository</h4><pre>cd /usr/src/kodekloudrepos/official</pre><h4>3. Check recent commits</h4><pre>sudo git log --oneline -n 2</pre><p>This command helps confirm the commit you’re about to revert.</p><h4>4. Revert the latest commit</h4><pre>sudo git revert HEAD</pre><h4>5. Commit the revert with the required message</h4><pre>sudo git commit --amend -m &quot;revert official&quot;</pre><h4>6. Confirm the revert was successful</h4><pre>sudo git log --oneline -n 3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*QHbhLb8P1L2nbO1qZBTtsA.png" /></figure><p>You should see a new commit on top with the message “<strong>revert official.</strong>”</p><h3>Day 28: Merge a Specific Commit From One Branch to Another With Git</h3><p>Day 28 task explains how to merge a single commit from a branch — not an entire branch — into a different branch. In this case, it was from the<strong> feature</strong> branch into the <strong>master </strong>branch in the Git repository <strong>/usr/src/kodekloudrepos/media </strong>on the storage server. The specific commit to merge has the message “<strong>Update info.txt.</strong>”</p><p>Here are the steps to follow:</p><h4>1. SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><h4>2. Switch to the root user</h4><pre>sudo -i</pre><p>This command allows you to run git commands inside the storage server without using <strong>sudo</strong>.</p><h4>3. Go to the repository</h4><pre>cd /usr/src/kodekloudrepos/media</pre><h4>4. Switch to and update the local master branch</h4><pre>git checkout master<br>git pull origin master</pre><h4>5. Check out the feature branch and get the commit ID</h4><pre>git checkout feature<br>git log --oneline</pre><p>Find the commit with the message <strong>“Update info.txt.” </strong>Copy its commit hash.</p><h4>6. Switch back to the master branch</h4><pre>git checkout master</pre><h4>7. Merge that single commit using cherry-pick</h4><pre>git cherry-pick 873a839</pre><p>Replace <strong>873a839 </strong>with the actual commit hash you copied previously.</p><h4>8. Push the changes to the remote repository</h4><pre>git push origin master</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/688/1*K3KWMVbgrad8UhrluQwYHg.png" /></figure><p>Only the commit with the message “<strong>Update info.txt</strong>” from the <em>feature </em>branch is now merged into <em>master </em>and pushed successfully.</p><h3>Day 29: Create and Review a Pull Request using Gitea UI</h3><p>Day 29 task explains how to properly merge code into the <strong>master </strong>branch using a <strong>Pull Request (PR)</strong> instead of pushing directly. You’ll log in as user <strong>Max</strong>, create a PR from the branch <em>story/fox-and-grapes</em><strong> </strong>to <em>master</em>, assign <strong>Tom</strong> as a reviewer, and then log in as Tom to review and merge it through the Gitea web interface.</p><p>Here are the steps to follow:</p><h4>1. SSH into the storage server as Max</h4><pre>ssh max@ststor01<br># Password: Max_pass123</pre><h4>2. List all the directory content and move into the cloned repository</h4><pre>ls -a &amp;&amp; cd story-blog<br></pre><h4>3. Confirm you’re in the ‘story/fox-and-grapes’ branch</h4><pre>git branch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/691/1*37kGnQP-fTARQ8MPVoniFQ.png" /></figure><h4>4. Check the commits info</h4><pre>git log --oneline</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*YlLlENkzqmC3rs8gYI6sFQ.png" /></figure><p>You should see Max’s commit (last commit) with the message “<strong>Added fox-and-grapes story</strong>.”</p><h4>5. Open the Gitea web interface</h4><p>Click the <strong>Gitea UI </strong>button at the top in the lab environment.</p><p>Log in with:<br> <strong>Username: </strong>max<br> <strong>Password: </strong>Max_pass123</p><h4>6. Create a Pull Request</h4><ul><li>Go to the repository page.</li><li>Click <strong>Pull Requests → New Pull Request</strong>.</li><li>Set the source branch to <em>story/fox-and-grapes and </em>the target branch to <em>master</em>.</li><li>Add this PR title:<br> <strong>Added fox-and-grapes story</strong></li><li>Click <strong>Create Pull Request</strong>.</li></ul><h4>7. Assign Tom as a reviewer</h4><ul><li>On the PR page, find the <strong>Reviewers</strong> section (on the right-hand side).</li><li>Click <strong>Reviewers</strong> and add <strong>Tom</strong> as a reviewer.</li></ul><h4>8. Log out as Max and log in as Tom</h4><ul><li>Log out of Gitea.</li><li>Log in again with:<br> <strong>Username: </strong>tom<br> <strong>Password: </strong>Tom_pass123</li></ul><h4>9. Review and merge the PR</h4><ul><li>Open the Pull Request titled <strong>“Added fox-and-grapes story.”</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F0KoDrnfuI4ILIxFNoeAkg.png" /></figure><ul><li>Review the changes and click <strong>Approve</strong>.</li><li>Then click <strong>Merge Pull Request</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-mYnwkRbG5gZBrAUdhSViA.png" /></figure><h4>10. Verify the merge in the terminal</h4><p>Switch to master branch, pull the latest changes, then check the logs:</p><pre>git checkout master<br>git pull origin master<br>git log --oneline</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*W9UzhGjootzs7DyCBro9kA.png" /></figure><p>You can see the <strong>merge pull request </strong>commit hash, which shows that the pull request merge was successful.</p><h3>Day 30: Reset Git Commit History to a Specific Commit</h3><p>This task explains how to clean up a Git repository by resetting its history and work tree to a specific commit — in this case, the one with the message “<strong>add data.txt file.</strong>” You’ll perform a hard reset so that only two commits remain: the <strong>initial commit</strong> and <strong>add data.txt file</strong>, and push the updated state to the remote repository.</p><p>Here are the steps to follow:</p><h4>1. SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><h4>2. Switch to the root user</h4><pre>sudo -i</pre><h4>3. Go to the cluster repository</h4><pre>cd /usr/src/kodekloudrepos/cluster</pre><h4>4. Check the commit history</h4><pre>git log --oneline</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*ijF2GP4Oit7AvMQXHCXXDw.png" /></figure><p>Locate the commit with the message <strong>“add data.txt file” </strong>and copy its hash.</p><h4>5. Reset the repo commit history to that commit</h4><p>Use a <strong>hard reset</strong> to point both HEAD and the branch to the chosen commit:</p><pre>git reset --hard e4302b7</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*oKyXKIi1worqEyrhMRDatQ.png" /></figure><p><strong>Note: </strong>Replace the above commit hash with the one you got from your git logs.</p><h4>6. Force-push the updated history to the remote repo</h4><pre>git push origin master --force</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*a5j09XNbWxbsFWtjBncHKg.png" /></figure><h4>7. Check the commit history to confirm the reset</h4><pre>git log --oneline</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/687/1*sIjVlewe5X0xdXcdY9UPMQ.png" /></figure><p>The repository now contains only two commits: the <strong>initial commit</strong> and <strong>add data.txt file, </strong>showing that the commit history was cleaned up successfully.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3798cbbe15cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[(Day 21–25) 100 Days of DevOps Challenge by KodeKloud]]></title>
            <link>https://medium.com/@ChinecheremU/day-21-25-100-days-of-devops-challenge-by-kodekloud-dad0cdf5d065?source=rss-89402fdfd0ec------2</link>
            <guid isPermaLink="false">https://medium.com/p/dad0cdf5d065</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[devops-challenges]]></category>
            <category><![CDATA[system-administration]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[kodekloud]]></category>
            <dc:creator><![CDATA[Chinecherem Udegbunam]]></dc:creator>
            <pubDate>Wed, 08 Oct 2025 04:49:01 GMT</pubDate>
            <atom:updated>2025-10-08T04:49:01.909Z</atom:updated>
            <content:encoded><![CDATA[<p>Days 21–25 of the <a href="https://kodekloud.com/100-days-of-devops"><em>100 Days of DevOps Challenge by KodeKloud</em></a> shifted focus to <strong>Git</strong>. The tasks covered setting up, cloning, and forking a Git repository. Additionally, it covered creating and merging branches using Git.</p><p>This part of the challenge reflects real-world Git workflows that DevOps engineers use daily—collaborating, conducting code reviews, and managing codebase changes smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*XsriBRWKMZVoGBEd.png" /><figcaption>100 Days of DevOps with KodeKloud</figcaption></figure><h3>Day 21: Set Up a Git Repository on the Storage Server</h3><p>For this task, the Nautilus DevOps team needed to prepare a central Git repository for a new application project. The repo will be hosted on the Storage Server in Stratos DC.</p><h4>Step 1: SSH into the storage server</h4><p><strong>Storage Server SSH Details:</strong></p><p>SSH User: natasha</p><p>Server Name: ststor01</p><pre>ssh natasha@ststor01</pre><h4>Step 2. Install Git</h4><p>Use <strong>yum </strong>to install Git on the Storage Server:</p><pre>sudo yum install git -y</pre><p>This command installs Git and all necessary dependencies.</p><h4>Step 3: Create the bare repository— <em>/opt/news.git</em></h4><pre>sudo git init --bare /opt/news.git</pre><p>-<strong>- bare </strong>initializes a repository that has no working directory and is typically used as a central repository for collaboration.</p><p><strong>news.git </strong>is the required name as specified in the task.</p><h4>Step 4: Verify the repo</h4><p>Confirm that the repository has been created:</p><pre>ls -ld /opt/news.git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*f8GxPIQcDrlWiQSI4LvU8A.png" /></figure><p>You can also view its content:</p><pre>ls /opt/news.git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*N4dNOJ_WUBO_lK-CdMUcHg.png" /></figure><p>You should see directories such as <em>branches, hooks, info, objects, refs</em>, etc.—like the one above, which confirms it’s a valid bare repository.</p><h3>Day 22: Clone an Existing Git Repository</h3><p>The instructions mentioned that the Nautilus development team requested a copy of a Git repository previously created by the DevOps team. Day 22&#39;s task was to clone the repository on the Storage Server to a specified directory.</p><h4>Step 1: SSH into the storage server</h4><p><strong>Storage Server SSH Details:</strong></p><p>SSH User: natasha</p><p>Server Name: ststor01</p><pre>ssh natasha@ststor01</pre><h4>Step 2. Navigate to the target directory</h4><p>Before cloning, use the <strong>ls </strong>command to confirm if the target directory exists. If not, create it:</p><pre>sudo mkdir -p /usr/src/kodekloudrepos<br>sudo chown natasha:natasha /usr/src/kodekloudrepos<br>cd /usr/src/kodekloudrepos</pre><p><strong>Note: </strong>Ownership is set to <strong>natasha</strong> to allow the user to perform the clone operation.</p><h4>Step 3. Clone the repository</h4><p>Clone the existing repository (<strong>/opt/demo.git</strong>) into the <em>/usr/src/kodekloudrepos </em>directory:</p><pre>git clone /opt/demo.git</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*pUpasATTMeQuHiOEMnrNRg.png" /></figure><p>This creates a new directory named <strong><em>&#39;demo&#39; </em></strong><em>inside /usr/src/kodekloudrepos, </em>containing the cloned repository.</p><h4>Step 4: Verify the clone</h4><p>After cloning, confirm the repository has been cloned successfully:</p><pre>ls -l /usr/src/kodekloudrepos</pre><p>You should see a directory named <strong>&#39;demo.&#39;</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*gFQyFtgPXvImr-w4JUBjGg.png" /></figure><p>Check that the cloned repository is valid:</p><pre>cd /usr/src/kodekloudrepos/demo<br>git status</pre><p>It should show:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*JYiNARtUs_oRfCFQcWv1GA.png" /></figure><p>This means the <strong>/opt/demo.git </strong>repository has been successfully cloned into the <em>/usr/src/kodekloudrepos </em>directory on the Storage Server, ready for use by the Nautilus application development team.</p><h3>Day 23: Fork an Existing Git Repository via Gitea</h3><p>A new developer, Jon, has joined the Nautilus team and needs his own copy of an existing project to start contributing. To achieve this, Jon (you) will fork the repository using the <strong>Gitea web interface</strong>.</p><h4>Step 1: Access the Gitea web interface</h4><p>Click the <strong>“Gitea UI”</strong> button in the top bar of the lab environment.</p><h4>Step 2: Log in as Jon</h4><p>Use the provided credentials to log in:</p><ul><li>Username:<strong> jon</strong></li><li>Password:<strong> Jon_pass123</strong></li></ul><p>After a successful login, you will be directed to Jon’s Gitea dashboard.</p><h4>Step 3. Locate the repository and fork it</h4><p>Find the repository named <strong>sarah/story-blog</strong> and click on the repository name to open it.</p><p>On the top-right of the repository page, click <strong>“Fork.”</strong> When prompted, select <strong>jon</strong> as the target user account to fork the repository into.</p><p>The forked repository will now appear under Jon’s account.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LdxehmjyABVV3aRhV3CgQ.png" /></figure><h3>Day 24: Create a New Git Branch in an Existing Repository</h3><p>The task was to create a new branch named <strong>xfusioncorp_games </strong>from the <strong>master </strong>branch in the repository located at <em>/usr/src/kodekloudrepos/games</em>. This should be done on the <strong>Storage Server</strong> in Stratos DC.<br><strong>Note: </strong>No code changes are required—just the branch creation.</p><h4>Step 1: SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><p><strong>Note:</strong> You can run the <strong>sudo -i</strong> command and do the tasks using the root user. If not, always add <strong>sudo </strong>when running the git commands.</p><h4>Step 2: Navigate to the repository</h4><pre>cd /usr/src/kodekloudrepos/games</pre><h4>Step 3: Check the current branch</h4><p>Verify that you’re on the <strong>master</strong> branch:</p><pre>git branch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*hBLBPSwAhXb95HUoJflzeA.png" /></figure><p>If you’re not on master, switch to it:</p><pre>git checkout master</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*6KClTiZAvQxa1dZ7Faoo2w.png" /></figure><h4>Step 4: Create the new branch</h4><pre>git checkout -b xfusioncorp_games</pre><h4>Step 5: Verify branch creation</h4><p>List all branches to confirm the new branch was created:</p><pre>git branch</pre><p>You should see:</p><pre>  kodekloud_games<br>  master<br>* xfusioncorp_games</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/682/1*H7MMDN4MS_ro5XBDvjwzGg.png" /></figure><h4>Step 6: Push the new branch to the remote repo</h4><pre>git push origin xfusioncorp_games</pre><p>A new branch named <strong>xfusioncorp_games </strong>has been successfully created from the <strong>master </strong>branch in the /usr/src/kodekloudrepos/beta repository.</p><h3>Day 25: <strong>Create a Branch, Add a File, Merge, and Push Changes in Git</strong></h3><p>You need to:</p><ol><li>Create a new branch named <strong>xfusion </strong>from the <strong>master </strong>branch.</li><li>Copy the provided <strong>/tmp/index.html </strong>file into the repo.</li><li>Add and commit the file in the xfusion branch.</li><li>Merge the xfusion branch back into master.</li><li>Push the changes for both branches (master and xfusion) to the remote origin.</li></ol><h4>Step 1: SSH into the storage server</h4><pre>ssh natasha@ststor01</pre><h4>Step 2: Navigate to the repo</h4><pre>cd /usr/src/kodekloudrepos/media</pre><h4>Step 3: Switch to the root user and check the current branch</h4><p>Switch to the root user to make running the commands easier.</p><pre>sudo -i</pre><p>Make sure you’re on master:</p><pre>git branch</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/694/1*zQ7JJpyFbUQ06uNuO7UCjg.png" /></figure><p>If you’re not on master, switch to it:</p><pre>git checkout master</pre><h4>Step 4: Create and switch to xfusion branch</h4><pre>git checkout -b xfusion</pre><p>This creates a new branch named <strong>xfusion </strong>and switches to it.</p><h4>Step 5: Copy the index.html file</h4><pre>cp /tmp/index.html .</pre><p>This copies the file into the repository’s root directory.</p><h4>Step 6: Add and commit the file</h4><pre>git add index.html<br>git commit -m &quot;Add index.html file as per xfusion branch requirements&quot;</pre><h4>Step 7: Push the xfusion branch to remote</h4><pre>git push origin xfusion</pre><h4>Step 8: Switch back to master</h4><pre>git checkout master</pre><h4>Step 9. Merge xfusion into master</h4><pre>git merge xfusion</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/695/1*H1Jynyg_A-HrXBMG546JAQ.png" /></figure><p>This integrates the changes from <strong>xfusion </strong>into <strong>master</strong>.</p><h4>Step 10: Push the updated master branch to remote</h4><pre>git push origin master</pre><h4>Step 11: Verify that everything worked successfully</h4><p>Check branches:</p><pre>git branch -a</pre><p>You should see both master and xfusion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*2F3Is_l8p8cfitsuPVp7tQ.png" /></figure><p>Check commit history:</p><pre>git log --oneline --graph --all</pre><p>You should see the merge commit on master.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*_tt4qg1POJtpKxq_wmQMqQ.png" /></figure><p>Confirm the <strong>index.html </strong>file exists in the repo:</p><pre>ls</pre><p>You should see it in the repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/689/1*Au7Uda27hVQS_EXZBPS7bA.png" /></figure><h3>Key Takeaways</h3><ul><li><strong>git branch -b &lt;new branch&gt; </strong>creates and switches to a new branch in one step.</li><li>Always commit changes in the feature branch before merging.</li><li>Push both branches to the remote repo so collaborators can access them.</li><li>Merging integrates the work done in the feature branch into the main branch.</li></ul><p>This task demonstrates a standard <strong>feature branch workflow</strong> used in collaborative software development.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dad0cdf5d065" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>