π DevSecOps Journey β Day 19

Real-World NGINX Projects: Static Hosting, Reverse Proxy & Load Balancing
NGINX is one of the most widely used tools in modern infrastructure.
Today, I worked on hands-on NGINX projects that reflect real production use cases, moving beyond theory into practical implementation.
These projects helped me understand how NGINX handles traffic, routing, scalability, and fault tolerance in real systems.
π§ Installing NGINX on Ubuntu
Before starting the projects, NGINX was installed on Ubuntu:
sudo apt update
sudo apt install nginx -y
NGINX runs as a service and listens on port 80 (HTTP) by default.
π Project 1: Serving a Static Website Using NGINX
πΉ Project Type: Static Web Hosting
πΉ Use Case: Hosting HTML/CSS/JS sites efficiently
πΉ GitHub Repo:
π π https://github.com/Jysh06/Nginx-Static-Website
π Step 1: Place Website Files
By default, NGINX serves content from:
/var/www/html
For this project, a custom directory was used:
sudo mkdir -p /var/www/static-site
sudo cp -r * /var/www/static-site
sudo chown -R www-data:www-data /var/www/static-site
βοΈ Step 2: Create a Virtual Host
NGINX allows multiple websites using virtual hosts:
server {
listen 80;
server_name skjptpp.in;
root /var/www/static-site;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}
π Directive Breakdown
listen 80 β Accept HTTP traffic
server_name β Domain mapping
root β Website directory
index β Default file
try_files β Safe file resolution
π Step 3: Enable & Reload
sudo ln -s /etc/nginx/sites-available/static-site /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
β Static website is now live after DNS configuration.
π¨ Bonus: Custom Error Pages (404 & 500)
β Default NGINX Errors
Plain
Not user-friendly
β Custom Error Pages
/var/www/mywebsite/
βββ 404.html
βββ 500.html
error_page 404 /404.html;
error_page 500 502 503 504 /500.html;
location = /404.html {
root /var/www/mywebsite;
internal;
}
location = /500.html {
root /var/www/mywebsite;
internal;
}
π internal ensures users canβt access error pages directly.
π Project 2: NGINX as a Reverse Proxy (Node.js Backend)
πΉ Project Type: Reverse Proxy + API Gateway
πΉ Use Case: Single entry point for frontend & backend
πΉ GitHub Repo:
π https://github.com/Jysh06/Nginx-node-proxy
π§ What This Project Demonstrates
NGINX serving frontend static files
NGINX routing
/apirequests to Node.js backendWebSocket support for real-time apps
location /api/ {
proxy_pass http://13.201.37.133:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
βΆοΈ Backend Setup
cd backend
npm install express cors socket.io
node index.js
This setup mirrors real API gateway patterns used in production.
βοΈ Project 3: NGINX as a Load Balancer
πΉ Project Type: Load Balancing
πΉ Use Case: High availability & scalability
πΉ GitHub Repo:
π https://github.com/Jysh06/Nginx-Loadbalancer
π Upstream Configuration
upstream backend_apis {
least_conn;
server 13.201.37.133:3001;
server 13.201.37.133:3002;
}
least_conn β Sends traffic to the least busy server
Improves performance during high traffic
π API Routing
location /api/ {
proxy_pass http://backend_apis;
}
π¦ Traffic Simulation
sudo apt install apache2-utils
ab -n 100 -c 10 http://skjptpp.in/api/
This helped visualize real load distribution across backends.
π― Why These Projects Matter in DevOps / DevSecOps
These NGINX projects covered:
Static content delivery
Reverse proxying
API gateway patterns
Load balancing strategies
Zero-downtime foundations
Real traffic simulation
All of these are core responsibilities in production DevOps environments.
β Day 19 Summary
Today I built:
π Static website hosting with NGINX
π Reverse proxy for Node.js APIs
βοΈ Load-balanced backend services
And learned:
Virtual hosts & routing
Error handling
Reverse proxy headers
Traffic distribution strategies
This hands-on experience strengthened my understanding of how NGINX powers real-world infrastructure.



