# 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.1` only ## Directory Structure ``` /docker/web-hosts/ ├── scripts/ │ └── hostctl.sh # Main management script ├── domains/ │ └── / # One directory per root domain │ ├── compose.yaml │ ├── www/ # Static files │ ├── data/ # Persistent data │ └── config/ # Configuration ``` ## Quick Start ### 1. Create a new domain ```bash /docker/web-hosts/scripts/hostctl.sh create example.com 9000 ``` This creates: - Directory structure at `/docker/web-hosts/domains/example.com/` - Template `compose.yaml` with services bound to `127.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 ```bash /docker/web-hosts/scripts/hostctl.sh start example.com ``` ### 4. Add nginx reverse proxy with SSL ```bash 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 ` | Start a domain | | `hostctl stop ` | Stop a domain | | `hostctl restart ` | Restart a domain | | `hostctl logs ` | View logs | | `hostctl create [port]` | Create new domain | | `hostctl remove ` | 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: - ``: Main website (www) - ``: API subdomain - ``: Additional services - etc. Example for `example.com` starting at port 9000: - `example.com` → `127.0.0.1:9000` - `api.example.com` → `127.0.0.1:9001` - `admin.example.com` → `127.0.0.1:9002` ## Architecture ``` Internet │ ▼ ┌─────────────────────────────────────┐ │ Nginx (rootful, ports 80/443) │ │ /docker/www/ │ │ - SSL termination │ │ - Reverse proxy │ └─────────────────────────────────────┘ │ ▼ 127.0.0.1: ┌─────────────────────────────────────┐ │ Podman Containers (rootless) │ │ /docker/web-hosts/domains/ │ │ - Web apps │ │ - APIs │ │ - Databases │ └─────────────────────────────────────┘ ``` ## Adding Subdomains 1. Add service to domain's `compose.yaml`: ```yaml services: api: image: your-api-image ports: - "127.0.0.1:9001:8080" ``` 2. Restart the domain: ```bash hostctl restart example.com ``` 3. Add nginx config for subdomain: ```bash sudo /docker/www/startup.sh add-domain api.example.com 9001 ```