Day 28: Nginx Setup & Reverse Proxy


Hey DevOps enthusiasts! π
Welcome to Day 28 of my journey. Today wraps up the final piece of our manual provisioning stack setup using Vagrant multi-VMs.
In this article, weβre focusing on setting up Nginx as a frontend web server that acts as a reverse proxy for our Java application running on Tomcat.
π Recap of the Stack So Far
Over the last few days, weβve:
β
Created a multi-VM setup with Vagrant
β
Installed and configured:
MySQL (Database)
Memcached (Caching)
RabbitMQ (Message Broker)
Tomcat (Application Server)
β Built and deployed a Java app using Maven
Now letβs connect it all with Nginx!
π Step 1: Access Nginx VM
vagrant ssh web01
$ sudo -i
β
Verify /etc/hosts
for proper hostname entries across VMs.
π Step 2: Update System & Install Nginx
apt update
apt install nginx -y
π Step 3: Configure Nginx
Create a new config file:
vi /etc/nginx/sites-available/vproapp
Paste the following:
upstream vproapp {
server app01:8080;
}
server {
listen 80;
location / {
proxy_pass http://vproapp;
}
}
π Step 4: Activate the Website
rm -rf /etc/nginx/sites-enabled/default
ln -s /etc/nginx/sites-available/vproapp /etc/nginx/sites-enabled/vproapp
π Step 5: Restart Nginx
systemctl restart nginx
β Visit your web server's IP address β you should now see the Java web application served via Nginx.
π§© How This Works
Nginx listens on port
80
.It forwards all traffic to
app01:8080
where Tomcat is running.Other backend services (MySQL, RabbitMQ, Memcached) are already wired via configuration.
β What We Accomplished in This 4-Part Series
Day | Component | Description |
25 | Vagrant VM Setup | Multi-stage Vagrantfile & networking |
26 | Memcached & RabbitMQ | Setup and service management |
27 | Tomcat & Code Deploy | Maven build and WAR deployment |
28 | Nginx Reverse Proxy | Web frontend and app integration |
π Final Thoughts
You now have a fully working Java stack setup manually with:
Configurable Vagrant VMs
Linux system administration
App deployment pipeline
This is a foundational setup before diving into automation with provisioning tools like Shell, Ansible, or Terraform β which Iβll cover next!
Stay Tuned!
Next week, Iβll rebuild this exact setup using Vagrant provisioning scripts to automate it all from scratch π
Until then, happy provisioning!
Subscribe to my newsletter
Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
