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.
- User Management: Supports multi-level user permissions (admin, advanced user, regular user)
- Lab Management: Create and configure different types of lab environments
- VM Management: Automatically clone and assign virtual machines to users or groups
- VMware API Integration: Integrate with vCenter server for automated operations
- Session Management: Use Redis to store user sessions, supporting cluster deployment
- Reverse Proxy: Integrated WebSocket proxy, supports direct access to ESXi hosts
- Secure Access: HTTPS support and user authentication
VLAB adopts a multi-layer architecture:
- Frontend: Web interface rendered by EJS templates and tailwindcss
- Application Layer: Node.js Express server
- Cache Layer: Redis for session storage and caching
- Storage Layer: PostgreSQL database
- Proxy Layer: Nginx/Node.js reverse proxy
- Virtualization Layer: VMware vCenter and ESXi
- Node.js 16+
- Redis 7+
- PostgreSQL 12+
- Tailwindcss 4+
- VMware vCenter server 7.0+
Create a .envrc file (refer to .envrc.example):
# VMware vCenter configuration
export VCENTER_BASE_URL="https://vcenter.example.com"
export VCENTER_USERNAME="administrator@vsphere.local"
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 detailsDocker 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.cjsThe 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:
- Create new routes in the
routes/directory - Add necessary views to the
views/directory - Update config files to support new features
- Rebuild the frontend with React/Vue for a more modern UI
- Adapting CSS for mobile devices
- For production, use PM2 for cluster deployment
- Use Nginx as a frontend proxy for static assets and load balancing
- Configure proper caching and connection pooling for Redis and PostgreSQL
Common issues and solutions:
- Connection issues: Ensure vCenter and ESXi hosts allow API access
- Session issues: Check Redis connection and configuration
- Proxy errors: Verify Nginx configuration and SSL certificates
















