Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multisite Nginx + Multi‑Backend Vagrant Environment

A fully automated, multi‑service DevOps environment featuring Python, Node.js, and Go backends, three static sites, Nginx virtual hosts, and systemd‑managed microservices — all provisioned inside a reproducible Vagrant VM.


📌 Overview

This project demonstrates a complete DevOps workflow:

  • Multi‑language backend services (Python, Node.js, Go)
  • Multiple instances of each backend (horizontal scaling)
  • Static websites served via Nginx
  • Nginx reverse proxy routing to backend services
  • systemd service management for backend processes
  • Automated provisioning using Bash
  • Reproducible environment using Vagrant + Ubuntu

📁 Folder Structure

multisite-nginx-github/
├── Vagrantfile
├── provisioning/
│   └── provision.sh
│
├── nginx/
│   ├── site1.conf
│   ├── site2.conf
│   └── site3.conf
│
├── systemd/
│   ├── python-backend.service
│   ├── python-backend-2.service
│   ├── node-backend.service
│   ├── node-backend-2.service
│   ├── go-backend.service
│   └── go-backend-2.service
│
├── python-backend/
│   ├── app.py
│   └── wsgi.py
│
├── node-backend/
│   ├── app.js
│   ├── package.json
│   └── package-lock.json
│
├── go-backend/
│   ├── main.go
│   └── go.mod
│
└── static-sites/
    ├── site1/public/index.html
    ├── site2/public/index.html
    └── site3/public/index.html

🏗 Architecture Diagram

                   ┌──────────────────────────────┐
                   │          Vagrant VM           │
                   │        Ubuntu (Jammy)         │
                   └──────────────────────────────┘
                                │
                                ▼
                    ┌──────────────────────┐
                    │        NGINX         │
                    │  Reverse Proxy +     │
                    │  Static Site Hosting │
                    └──────────────────────┘
                     /       |        \
                    /        |         \
                   ▼         ▼          ▼
        ┌────────────────┐ ┌────────────────┐ ┌────────────────┐
        │   site1.conf   │ │   site2.conf   │ │   site3.conf   │
        │  static site   │ │  Python API    │ │  Node API      │
        └────────────────┘ └────────────────┘ └────────────────┘
                                          \
                                           \
                                            ▼
                                 ┌──────────────────┐
                                 │   Go API         │
                                 └──────────────────┘

⚙ Backend Architecture (Multi‑Instance)

Each backend runs two systemd services, simulating horizontal scaling:

Python:
  python-backend.service        → port 5001
  python-backend-2.service      → port 5002

Node:
  node-backend.service          → port 3001
  node-backend-2.service        → port 3002

Go:
  go-backend.service            → port 8001
  go-backend-2.service          → port 8002

Nginx routes traffic to these services using upstream blocks (round‑robin load balancing).


🔧 Provisioning Flow

The provisioning script (provision.sh) automates:

  1. Install Nginx, Python, Node.js, Go
  2. Install backend dependencies
  3. Build Go backend
  4. Copy systemd service files
  5. Enable + start all backend services
  6. Copy Nginx configs
  7. Enable sites + restart Nginx

🌐 Nginx Routing

Static Sites

site1.local → static-sites/site1/public/index.html
site2.local → static-sites/site2/public/index.html
site3.local → static-sites/site3/public/index.html

Backend Routing

/python → python-backend.service + python-backend-2.service
/node   → node-backend.service + node-backend-2.service
/go     → go-backend.service + go-backend-2.service

Each backend has an upstream block:

upstream python_backend {
    server 127.0.0.1:5001;
    server 127.0.0.1:5002;
}

🧩 systemd Service Management

Example: python-backend.service

[Unit]
Description=Python Backend Service
After=network.target

[Service]
ExecStart=/usr/bin/python3 /home/vagrant/python-backend/app.py
Restart=always
User=vagrant

[Install]
WantedBy=multi-user.target

Manage services:

sudo systemctl status python-backend
sudo systemctl restart node-backend-2
sudo systemctl enable go-backend

🚀 Running the Project

Start the VM

vagrant up

SSH into the VM

vagrant ssh

Test static sites

http://site1.local
http://site2.local
http://site3.local

Test backend APIs

curl http://localhost/python
curl http://localhost/node
curl http://localhost/go

🧪 Testing Load Balancing

curl http://localhost/python
curl http://localhost/python
curl http://localhost/python

You should see alternating responses from instance 1 and instance 2.


📜 Technologies Used

  • Vagrant
  • Ubuntu Linux
  • Nginx
  • systemd
  • Python / Flask
  • Node.js / Express
  • Go / net/http
  • Bash

📚 Future Enhancements

  • Add Docker support
  • Add CI/CD pipeline
  • Add monitoring (Prometheus + Grafana)
  • Add log aggregation (ELK stack)

🙌 Author

Abiola — DevOps Engineer
St. Paul, Minnesota
Building scalable, automated infrastructure.

About

Multi‑backend DevOps environment with Nginx reverse proxy, systemd service orchestration, automated provisioning, and Vagrant‑based reproducible infrastructure.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages