Tools: From 500 Errors to a Fully Working Cloud App: My EpicBook Deployment on Azure

Tools: From 500 Errors to a Fully Working Cloud App: My EpicBook Deployment on Azure

DevOps #Terraform #Ansible #Azure #NodeJS #CloudComputing #LearningInPublic This week, I moved beyond simple deployments and built a real-world, multi-tier application architecture using Terraform + Ansible + Nginx + Node.js + MySQL on Microsoft Azure.

And honestly? It didn’t work at first.But that’s where the real learning happened.Let me walk you through the full journey, including the mistakes, fixes, and key DevOps lessons you can apply immediately. The GoalDeploy a production-style web application (EpicBook) with:🌐 Web Layer → Nginx (Reverse Proxy)⚙️ App Layer → Node.js (Express app)🗄️ Database Layer → MySQL (separate VM)🏗️ Infrastructure → Terraform🤖 Automation → Ansible Step 1: Provisioning Infrastructure with TerraformInstead of manually creating servers, I used Terraform to spin up:4 Virtual Machines (web1, web2, app, db)Virtual Network + SubnetsPublic IPsNetwork Security Groupsterraform initterraform planterraform apply Lesson: Infrastructure should be code. If you can’t recreate it in minutes, it’s not production-ready. Step 2: SSH Setup (First Real Problem)After provisioning, Ansible couldn’t connect:UNREACHABLE! SSH host key verification failed Why does this happen?Every time Terraform creates new VMs, they get new SSH fingerprints.Fix:ssh-keyscan -H >> ~/.ssh/known_hosts Lesson: Always run ssh-keyscan after redeploying infrastructure. Step 3: Running AnsibleI executed my playbook:ansible-playbook -i inventory.ini site.yml ✔ Everything passed✔ No errorsBut then I opened the browser… Step 4: The 500 Internal Server Error500 Internal Server Errornginx/1.18.0 At this point, many people would think:“But Ansible said SUCCESS…”This is where DevOps thinking matters. Step 5: Debugging the ProblemI inspected the application:cat /var/www/epicbook/server.js Discovery:It’s a Node.js appRuns on port 8080Not a static websiteThe mistake:I configured Nginx like this:root /var/www/epicbook; That only works for HTML files, not backend apps. Step 6: Fixing the ArchitectureThis was the turning point.✅ Fix 1: Nginx Reverse Proxylocation / { proxy_pass http://localhost:8080;} Now Nginx forwards traffic to Node.js. ✅ Fix 2: Install Node.js ✅ Fix 3: Install Dependencies ✅ Fix 4: Run App as a ServiceCreated a systemd service:ExecStart=/usr/bin/node server.js ✅ Fix 5: Database SetupInstalled MySQL on the DB serverCreated:database: bookstoreuser: epicbook ✅ Fix 6: Use Private Network (CRITICAL)Instead of:"host": "127.0.0.1" I used:"host": "10.0.1.7" Lesson: Databases should NEVER be exposed publicly.Other Errors I Encountered ✔ Fix: Remove and re-clone the directory ✔ Fix: Retry + verify connectivity Final ResultAfter fixing everything:✅ App running on both web servers✅ Nginx routing traffic correctly✅ Node.js processing requests✅ MySQL storing dataOpen in browser:http://http:// Idempotency CheckI ran the playbook again:ansible-playbook -i inventory.ini site.yml ✔ changed=0 Lesson: Good automation should be safe to run multiple times. What I Learned (The Real Value)This assignment wasn’t just about tools it was about thinking like a DevOps engineer.Key Takeaways:✔ “Success” in automation doesn’t mean the app works✔ Always verify in the browser (real user test)✔ Understand your application (Node.js ≠ static site)✔ Debugging is more important than writing code✔ Architecture decisions matter more than commands Final InsightA deployment is only successful when a real user can access the application — not when the playbook says “OK”. If You're Learning DevOps…Start building projects like this:Multi-tier appsReal debugging scenariosInfrastructure + application togetherThat’s how you move from:👉 “I know commands”to👉 “I can solve real-world problems” Let’s ConnectIf you’re also learning DevOps or working on similar projects, I’d love to connect and learn together. Templates let you quickly answer FAQs or store snippets for re-use. as well , this person and/or - name: Install Node.jsapt:name: nodejsstate: present - name: Install npm packagesnpm:path: /var/www/epicbook - Git “Dubious Ownership”fatal: detected dubious ownership - SSH TimeoutConnection timed out