Web Hosts Management
Overview
This system manages web hosting for multiple domains using:
- Podman Compose - Container orchestration (rootless)
- Nginx - Reverse proxy with SSL (rootful, via sudo)
- All services bind to
127.0.0.1only
Directory Structure
/docker/web-hosts/
├── scripts/
│ └── hostctl.sh # Main management script
├── domains/
│ └── <domain>/ # One directory per root domain
│ ├── compose.yaml
│ ├── www/ # Static files
│ ├── data/ # Persistent data
│ └── config/ # Configuration
Quick Start
1. Create a new domain
/docker/web-hosts/scripts/hostctl.sh create example.com 9000
This creates:
- Directory structure at
/docker/web-hosts/domains/example.com/ - Template
compose.yamlwith services bound to127.0.0.1:9000 - Default
index.html
2. Customize the compose file
Edit /docker/web-hosts/domains/example.com/compose.yaml to add your services.
3. Start the domain
/docker/web-hosts/scripts/hostctl.sh start example.com
4. Add nginx reverse proxy with SSL
sudo /docker/www/startup.sh add-domain example.com 9000
Commands Reference
| Command | Description |
|---|---|
hostctl list |
List all configured domains |
hostctl status [domain] |
Show status |
hostctl start <domain> |
Start a domain |
hostctl stop <domain> |
Stop a domain |
hostctl restart <domain> |
Restart a domain |
hostctl logs <domain> |
View logs |
hostctl create <domain> [port] |
Create new domain |
hostctl remove <domain> |
Remove a domain |
hostctl start-all |
Start all domains |
hostctl stop-all |
Stop all domains |
Port Assignment Convention
Each root domain gets a port range starting from the specified port:
<port>: Main website (www)<port+1>: API subdomain<port+2>: Additional services- etc.
Example for example.com starting at port 9000:
example.com→127.0.0.1:9000api.example.com→127.0.0.1:9001admin.example.com→127.0.0.1:9002
Architecture
Internet
│
▼
┌─────────────────────────────────────┐
│ Nginx (rootful, ports 80/443) │
│ /docker/www/ │
│ - SSL termination │
│ - Reverse proxy │
└─────────────────────────────────────┘
│
▼ 127.0.0.1:<port>
┌─────────────────────────────────────┐
│ Podman Containers (rootless) │
│ /docker/web-hosts/domains/ │
│ - Web apps │
│ - APIs │
│ - Databases │
└─────────────────────────────────────┘
Adding Subdomains
- Add service to domain's
compose.yaml:
services:
api:
image: your-api-image
ports:
- "127.0.0.1:9001:8080"
- Restart the domain:
hostctl restart example.com
- Add nginx config for subdomain:
sudo /docker/www/startup.sh add-domain api.example.com 9001