NGINX Unit
Dynamic application server supporting multiple languages.
Overview
NGINX Unit is a dynamic application server developed by NGINX Inc. that revolutionizes web application deployment by supporting multiple programming languages within a single server process. Unlike traditional web servers that require separate processes or modules for different languages, Unit can natively execute PHP, Python, Go, Ruby, Node.js, Java, and Perl applications through its polyglot architecture. This eliminates the complexity of managing multiple application servers and reduces resource overhead significantly.
NGINX Unit's standout capability is its dynamic reconfiguration system that operates through a REST API, allowing administrators to modify application configurations, routing rules, and server settings without requiring restarts or service interruptions. The server maintains application state during configuration changes, enabling true zero-downtime deployments. This makes Unit particularly valuable for organizations running mixed-language environments or requiring frequent deployment cycles without service disruption.
This setup is ideal for development teams working with microservices in different languages, hosting providers managing multi-tenant applications, and organizations seeking to consolidate their application server infrastructure. Unit's ability to handle multiple applications simultaneously while providing isolated execution environments makes it perfect for reducing operational complexity while maintaining performance and security boundaries between applications.
Key Features
- Native multi-language support for PHP, Python, Go, Ruby, Node.js, Java, and Perl in a single server process
- Dynamic reconfiguration via REST API without service restarts or downtime
- Zero-downtime application deployments with graceful configuration transitions
- Per-application isolation with independent memory spaces and resource limits
- Advanced request routing with pattern matching, load balancing, and traffic splitting
- Real-time statistics and monitoring through the control API endpoint
- Automatic process management with configurable limits and scaling policies
- Built-in support for WebSocket connections across all supported languages
Common Use Cases
- 1Multi-language microservices architecture requiring a unified application server
- 2Development environments needing to test applications in different programming languages
- 3Continuous integration pipelines requiring zero-downtime deployments
- 4Hosting platforms serving multiple customer applications with different language requirements
- 5A/B testing environments with traffic splitting between application versions
- 6Legacy application modernization where different components use different languages
- 7Educational platforms demonstrating web applications across multiple programming languages
Prerequisites
- Minimum 512MB RAM recommended for running multiple language runtimes
- Docker and Docker Compose installed on the host system
- Port 80 and 8080 available on the host machine
- Basic understanding of JSON configuration format for Unit setup
- Familiarity with REST API concepts for dynamic configuration management
- Application code prepared in supported languages (PHP, Python, Go, Ruby, Node.js, Java, Perl)
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 unit: 3 image: unit:latest4 container_name: nginx-unit5 restart: unless-stopped6 volumes: 7 - ./app:/www8 - ./unit/config.json:/docker-entrypoint.d/config.json:ro9 ports: 10 - "80:80"11 - "8080:8080"12 networks: 13 - unit-network1415networks: 16 unit-network: 17 driver: bridge.env Template
.env
1# NGINX Unit configuration via JSONUsage Notes
- 1Docs: https://unit.nginx.org/
- 2Polyglot server: PHP, Python, Go, Ruby, Node.js, Java, Perl
- 3Dynamic reconfiguration via REST API - no restarts needed
- 4Control API: curl --unix-socket /var/run/control.unit.sock http://localhost/
- 5Zero downtime deployments - change config on the fly
- 6Configure via JSON - applications, routes, listeners
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 unit:5 image: unit:latest6 container_name: nginx-unit7 restart: unless-stopped8 volumes:9 - ./app:/www10 - ./unit/config.json:/docker-entrypoint.d/config.json:ro11 ports:12 - "80:80"13 - "8080:8080"14 networks:15 - unit-network1617networks:18 unit-network:19 driver: bridge20EOF2122# 2. Create the .env file23cat > .env << 'EOF'24# NGINX Unit configuration via JSON25EOF2627# 3. Start the services28docker compose up -d2930# 4. View logs31docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/unit/run | bashTroubleshooting
- Unit control socket permission denied: Ensure the container has proper permissions to access /var/run/control.unit.sock
- Application fails to start with 'module not found': Verify the application path is correctly mounted and accessible within the container
- Configuration API returns 400 Bad Request: Validate JSON configuration syntax using a JSON validator before applying
- Multiple language applications conflict: Check that each application has unique listeners and properly isolated working directories
- Memory exhaustion with multiple apps: Adjust per-application process limits in Unit configuration and increase container memory limits
- Port binding fails on startup: Verify ports 80 and 8080 are not in use by other services on the host system
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
nginx-unit
Tags
#nginx-unit#polyglot#dynamic#app-server
Category
Web Servers & Reverse ProxiesAd Space
Shortcuts: C CopyF FavoriteD Download