🚀 Complete SSL-enabled Nginx automation - From certificates to running containers in one command.
# Create and start a complete project
keynginx init --domain myapp.local
cd keynginx-output
keynginx up
# 🌐 Visit https://localhost:8443KeyNginx eliminates the tedious process of setting up secure development servers by automating:
- 🔐 SSL Certificate Generation - Self-signed certificates with proper SAN support
- ⚙️ Nginx Configuration - Production-ready configs with security headers
- 🐳 Docker Orchestration - Complete container lifecycle management
- 🛡️ Security Headers - HSTS, CSP, XSS protection, and more
- 🔄 Service Proxying - Multi-service reverse proxy configuration
graph TD
A[keynginx init] --> B[Generate SSL Certs]
A --> C[Create Nginx Config]
A --> D[Generate Docker Compose]
A --> E[Save Project Config]
B --> F[ssl/private.key]
B --> G[ssl/certificate.crt]
C --> H[nginx.conf]
C --> I[Security Headers]
C --> J[Service Proxies]
D --> K[docker-compose.yml]
D --> L[Container Networks]
E --> M[keynginx.yaml]
F --> N[keynginx up]
G --> N
H --> N
K --> N
M --> N
N --> O[🚀 Running HTTPS Server]
- RSA key generation (2048, 3072, 4096 bits)
- Self-signed certificates with SAN support
- Localhost and custom domain support
- Proper file permissions (600 for private keys)
- Certificate validation and expiry checking
- HTTP to HTTPS automatic redirect
- Modern TLS 1.2/1.3 configuration
- Gzip compression optimization
- Comprehensive security headers
- Health check endpoints
- Multi-service reverse proxy support
- Container lifecycle management (create, start, stop, remove)
- Real-time status monitoring
- Log streaming and management
- Automatic port mapping
- Volume mounting for SSL and configs
- Health checks and readiness probes
| Profile | Use Case | Features |
|---|---|---|
| Strict | Production APIs | Maximum security, strict CSP, HSTS preload |
| Balanced | Most web apps | Good security + compatibility (default) |
| Permissive | Legacy apps | Basic headers, maximum compatibility |
- Go 1.21 or later
- Docker Desktop or Docker Engine
- Git (for cloning)
# Clone the repository
git clone https://github.com/sinhaparth5/keynginx
cd keynginx
# Install dependencies
go mod download
# Build
make build
# Install globally (optional)
make install# Check KeyNginx version
./dist/keynginx version
# Verify Docker is available
docker --version
docker ps# Initialize new project
keynginx init [flags]
# Start containers
keynginx up [flags]
# Stop and remove containers
keynginx down [flags]
# Check project status
keynginx status [flags]
# View container logs
keynginx logs [flags]# Generate certificates only
keynginx certs [flags]
# Validate existing certificates
keynginx certs --validate /path/to/cert.crt# Show version information
keynginx version
# Get help for any command
keynginx <command> --help# Simple localhost setup
keynginx init --domain localhost
cd keynginx-output
keynginx up
# Custom domain
keynginx init --domain myapp.local --output ./myapp
cd myapp
keynginx up# API with frontend and backend services
keynginx init \
--domain api.local \
--services "frontend:3000:/,backend:8000:/api" \
--custom-headers "X-API-Version:v2.0,X-Environment:development" \
--security-level strict \
--output ./api-project
cd api-project
keynginx up
# Check everything is running
keynginx status
# View real-time logs
keynginx logs -f# Generate high-security certificates
keynginx certs \
--domain secure.local \
--key-size 4096 \
--validity 730 \
--country US \
--state CA \
--organization "My Company" \
--out ./secure-certs
# Validate certificates
keynginx certs --validate ./secure-certs/certificate.crt# Start with recreate
keynginx up --recreate
# Stop without removing
keynginx down --remove=false
# Check all KeyNginx containers
keynginx status --all
# View logs (last 50 lines)
keynginx logs --tail 50myapp/
├── ssl/
│ ├── private.key # 🔑 SSL private key (600 permissions)
│ └── certificate.crt # 📜 SSL certificate (644 permissions)
├── nginx.conf # ⚙️ Production-ready Nginx config
├── docker-compose.yml # 🐳 Container orchestration
├── keynginx.yaml # 💾 Project configuration
└── logs/ # 📋 Nginx access/error logs (created on run)
security:
level: strict
enable_hsts: true
hsts_max_age: 63072000 # 2 years
enable_csp: true
csp_policy: "default-src 'self'; script-src 'self';"security:
level: balanced
enable_hsts: true
hsts_max_age: 31536000 # 1 year
enable_csp: true
csp_policy: "default-src 'self'; script-src 'self' 'unsafe-inline';"security:
level: permissive
enable_hsts: false
enable_csp: falsenginx:
services:
- name: frontend
port: 3000
path: /
proxy_pass: http://frontend:3000
- name: backend
port: 8000
path: /api
proxy_pass: http://backend:8000sequenceDiagram
participant Dev as Developer
participant KeyNginx
participant Docker
participant Browser
Dev->>KeyNginx: keynginx init --domain myapp.local
KeyNginx->>KeyNginx: Generate SSL certificates
KeyNginx->>KeyNginx: Create nginx.conf with security headers
KeyNginx->>KeyNginx: Generate docker-compose.yml
KeyNginx-->>Dev: ✅ Project created in ./keynginx-output/
Dev->>KeyNginx: cd keynginx-output && keynginx up
KeyNginx->>Docker: Create nginx container
KeyNginx->>Docker: Mount SSL certs & config
KeyNginx->>Docker: Start container on port 8443
Docker-->>KeyNginx: Container running
KeyNginx-->>Dev: 🚀 Server ready at https://localhost:8443
Dev->>Browser: Visit https://localhost:8443
Browser->>Docker: HTTPS request
Docker->>Docker: Nginx processes request
Docker-->>Browser: Secure response with headers
Dev->>KeyNginx: keynginx status
KeyNginx->>Docker: Get container info
Docker-->>KeyNginx: Container status
KeyNginx-->>Dev: 📊 Status: running, ports, URLs
Dev->>KeyNginx: keynginx logs -f
KeyNginx->>Docker: Stream container logs
Docker-->>Dev: 📋 Real-time nginx logs
Dev->>KeyNginx: keynginx down
KeyNginx->>Docker: Stop & remove container
Docker-->>KeyNginx: Container stopped
KeyNginx-->>Dev: ✅ Server stopped
| Flag | Short | Description | Default |
|---|---|---|---|
--verbose |
-v |
Verbose output | false |
--quiet |
-q |
Quiet mode | false |
--config |
Custom config file | ~/.keynginx.yaml |
| Flag | Description | Default | Example |
|---|---|---|---|
--domain -d |
Domain name | localhost |
--domain api.local |
--output -o |
Output directory | ./keynginx-output |
--output ./myapp |
--interactive -i |
Interactive mode | false |
--interactive |
--security-level |
Security profile | balanced |
--security-level strict |
--https-port |
HTTPS port | 8443 |
--https-port 443 |
--http-port |
HTTP port | 8080 |
--http-port 80 |
--services |
Service configs | --services "app:3000:/,api:8000:/api" |
|
--custom-headers |
Custom headers | --custom-headers "X-Version:2.0" |
|
--overwrite |
Overwrite existing | false |
--overwrite |
| Flag | Description | Default |
|---|---|---|
--project -p |
Project directory | . |
--detach -d |
Run in background | true |
--recreate |
Recreate containers | false |
| Flag | Description | Default |
|---|---|---|
--project -p |
Project directory | . |
--remove |
Remove containers | true |
--force |
Force stop | false |
| Flag | Description | Default |
|---|---|---|
--project -p |
Project directory | . |
--follow -f |
Follow logs | false |
--tail |
Lines from end | 100 |
| Flag | Description | Default |
|---|---|---|
--domain -d |
Domain name | localhost |
--out -o |
Output directory | ./ssl |
--key-size |
RSA key size | 2048 |
--validity |
Days valid | 365 |
--country |
Country code | US |
--organization |
Organization | KeyNginx Generated |
# Setup development environment
make setup-dev
# Run all tests
make test
# Format code
make fmt
# Check Docker availability
make docker-check# Test complete workflow
make test-workflow
# Test individual features
make test-up
make test-status
make test-logs
# Clean up test projects
make clean-tests# Build for current platform
make build
# Build for all platforms
make build-all
# Create release
make release# Check Docker status
docker --version
docker ps
# Start Docker Desktop (macOS/Windows)
# or start Docker daemon (Linux)
sudo systemctl start docker# Check what's using the port
lsof -i :8443
# Use different ports
keynginx init --https-port 9443 --http-port 9080# Check container logs
keynginx logs
# Recreate container
keynginx down
keynginx up --recreate
# Check nginx config syntax
docker run --rm -v $(pwd)/nginx.conf:/etc/nginx/nginx.conf:ro nginx nginx -t# Validate certificates
keynginx certs --validate ./ssl/certificate.crt
# Regenerate certificates
keynginx certs --domain yourdomain.local --out ./ssl --overwrite- Check command help:
keynginx <command> --help - Enable verbose output:
keynginx --verbose <command> - Check container logs:
keynginx logs -f - Verify project status:
keynginx status --json
- Self-signed certificates: Generated certificates are for development only
- Browser warnings: Users will see security warnings for self-signed certificates
- Production deployment: Use Let's Encrypt or commercial certificates for production
- Local development: Perfect for local development and testing environments
KeyNginx automatically includes modern security headers:
# Always included
X-Server-Created-By: keynginx
X-Content-Type-Options: nosniff
# Security level dependent
X-Frame-Options: SAMEORIGIN|DENY
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000
Content-Security-Policy: [configurable]
Referrer-Policy: strict-origin-when-cross-originKeyNginx sets proper file permissions:
- Private keys:
600(owner read/write only) - Certificates:
644(world readable) - Config files:
644(world readable)
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Run
make testandmake fmt - Submit a pull request
Please use the GitHub issue tracker to report bugs or request features.
- ✅ SSL certificate generation
- ✅ Nginx configuration with security headers
- ✅ Docker container management
- ✅ Multi-service reverse proxy
- ✅ Real-time logging and monitoring
- 🔄 Let's Encrypt integration
- 🔄 Certificate auto-renewal
- 🔄 Advanced rate limiting
- 🔄 WAF (Web Application Firewall) rules
- 🔄 Load balancing support
- 🔄 Health check configurations
- 🔄 Monitoring and metrics
- 🔄 Configuration templates
- 🔄 Cloud provider integration
- 🔄 Kubernetes manifests
- 🔄 CI/CD pipeline templates
- 🔄 Infrastructure as Code
This project is licensed under the MIT License - see the LICENSE file for details.
- Nginx - High-performance web server
- Docker - Containerization platform
- Cobra - CLI framework for Go
- Go Community - Amazing language and ecosystem
Built with ❤️ in Go | Powered by Nginx & Docker | Made for Developers
"From zero to HTTPS in 30 seconds" ⚡
- 📚 Documentation
- 🐛 Issues
- 💬 Discussions
- 🚀 Releases
- 🏗️ Examples