VLAB is a virtualization lab management system built with Express.js, designed to simplify the management, cloning, and access control of virtual machines in VMware environments, providing convenience for educational scenarios. The system offers a web interface that allows instructors to easily create and manage lab environments, and provides students with convenient access.
VLAB adopts a multi-layer architecture:
Create a .envrc
file (refer to .envrc.example
):
# VMware vCenter configuration
export VCENTER_BASE_URL="https://vcenter.example.com"
export VCENTER_USERNAME="[email protected]"
export VCENTER_PASSWORD="your-password"
# Database configuration
export DB_HOST="localhost"
export DB_USER="admin"
export DB_PASSWORD="your-db-password"
export DB_PORT=5432
export DB_NAME="vlab"
# Session configuration
export SESSION_SECRET="your-session-secret"
# Redis configuration
export REDIS_HOST="localhost"
export REDIS_PORT=6379
export REDIS_PASSWORD="your-redis-password"
# Proxy configuration
export PROXY_HOST="vlab.sample.com:8843"
# Install dependencies
npm install
# Create database (if using PostgreSQL)
psql -U postgres -c "CREATE DATABASE vlab;"
# For table creation, see the three init scripts in the db folder
# Start the application
npm run dev
npm run rproxy
# See depoyment_note.txt for details
Docker configuration files are provided for simplified deployment. Database and nginx can use official docker images directly:
# postgresql: main database (required)
docker-compose -f docker/docker-compose.pg.yml up -d
# For expressjs session storage (optional)
docker-compose -f docker/docker-compose.redis.yml up -d
# nginx: replaces rproxy.js as the proxy server in production (optional, do not run with rproxy at the same time)
docker-compose -f docker/docker-compose.nginx.yml up -d
# Start the application with PM2
npm install pm2 -g
pm2 start ecosystem.config.cjs
Login: Log in with assigned credentials
Access Labs and VMs: Connect to virtual machines via the web interface
User Management: Create users and groups, set permissions
Lab Configuration: Set up lab templates and VM assignment
Schedules and Tasks: Set shutdown schedules for lab VMs
The system provides a monitoring interface to display resource usage and user activity:
├── cert/ # SSL certificates
├── config.js # Application config
├── crontask/ # Scheduled tasks
├── db/ # Database scripts
├── docker/ # Docker configs
├── docs/ # Documentation and screenshots
├── middleware/ # Express middleware
├── public/ # Static assets
├── routes/ # Route definitions
├── server.js # App entry point
├── server-with-redis.js # Server with Redis support
├── rproxy.js # Reverse proxy server
└── views/ # EJS templates
To add new features, follow these steps:
routes/
directoryviews/
directoryCommon issues and solutions: