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

DayComponentDescription
25Vagrant VM SetupMulti-stage Vagrantfile & networking
26Memcached & RabbitMQSetup and service management
27Tomcat & Code DeployMaven build and WAR deployment
28Nginx Reverse ProxyWeb 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!


0
Subscribe to my newsletter

Read articles from Shaharyar Shakir directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Shaharyar Shakir
Shaharyar Shakir