A fast, lightweight, and dependency-free CLI tool written in Bash to automate Virtual Host management and SSL provisioning for Nginx and Caddy.
Whether you need to quickly expose a Node.js/Python app via a reverse proxy, host a static site, or deploy a Single Page Application (SPA) with fallback routing, vhost handles the boilerplate and Let's Encrypt certificates for you in seconds.
- Auto-Detects Web Server: Works seamlessly with Caddy or Nginx.
- Reverse Proxy Mode: Easily proxy traffic to local ports (e.g., Next.js, Express, Docker containers).
- SPA Routing: Built-in
try_filesconfiguration for React, Vue, or Angular apps. - Automated SSL: Zero-downtime Let's Encrypt integration via Certbot (for Nginx) or native ACME (for Caddy).
- Naked Domain Redirects: Automatically redirects
domain.comtowww.domain.com(or vice versa). - JSON Output: Run
listorinspectwith--jsonfor easy integration with dashboards or automation tools.
Run the following command to download and install vhost globally on your Linux server:
curl -sL https://raw.githubusercontent.com/talamantesvictor/vhost-cli/main/install.sh | bashNote: The installation requires sudo to place the executable in /usr/local/bin.
vhost requires root privileges to modify server configurations and reload services.
Syntax:
sudo vhost <action> [options] [domain]| Action | Description |
|---|---|
add |
Creates a new virtual host and attempts SSL generation. |
remove |
Deletes an existing virtual host and its certificates. |
list |
Lists all configured domains on the server. |
inspect |
Shows detailed info about a specific domain (target, type, SSL status/expiry). |
| Flag | Description |
|---|---|
-p <port> |
Reverse proxy target port (e.g., 3000). |
-n <domain> |
Naked domain redirect (e.g., domain.com -> www.domain.com). |
-e <email> |
Email for Let's Encrypt notifications (Highly recommended for Nginx). |
-a |
Enable SPA mode (fallback routing to /index.html). |
-s |
Force HTTPS redirect (Enabled by default). |
--wildcard |
Enable wildcard SSL (*.domain.com). |
| Flag | Description |
|---|---|
--caddy |
Force Caddy server detection. |
--nginx |
Force Nginx server detection. |
--json |
Output results in JSON format (only for list & inspect). |
1. Create a Reverse Proxy (Node.js/Docker) Proxy a domain to a local service running on port 3000:
sudo vhost add -p 3000 api.mydomain.com2. Host a Static Website (or SPA)
Serve static files and route 404s to index.html (Perfect for React/Vue):
sudo vhost add -a myapp.com3. Setup Domain + www Redirect + SSL Email
Configure www.domain.com, redirect domain.com to it, and register Let's Encrypt with your email:
sudo vhost add -n domain.com -e me@myemail.com www.domain.com4. List all sites and Inspect a specific domain
sudo vhost list
sudo vhost inspect myapp.com
# Use --json for API-friendly output
sudo vhost list --json
sudo vhost inspect myapp.com --json- A Linux environment (Debian/Ubuntu recommended)
- Root (
sudo) access - Nginx +
certbotOR Caddy - Basic DNS utilities (
dnsutilspackage fordig, optional but recommended for pre-flight checks).
MIT License