This guide will walk you through setting up a system to serve your local VMs over HTTPS using custom domain names (e.g., https://xyz.local). We'll use the following components:
- Hypervisor (e.g., VirtualBox, VMware, or Hyper-V)
- CoreDNS for local DNS resolution
- NGINX as a reverse proxy
- Smallstep/certificates for certificate management
- Install your chosen hypervisor (VirtualBox, VMware, or Hyper-V).
- Create VMs for each service you want to run.
- Configure the VMs to use bridged networking so they're accessible on your local network.
- Note down the IP addresses assigned to each VM.
-
Create a new VM to act as your DNS server.
-
Install CoreDNS on this VM.
-
Configure CoreDNS:
xyz.local:53 { hosts { 192.168.1.101 app1.xyz.local 192.168.1.102 app2.xyz.local 192.168.1.103 ca.xyz.local fallthrough } log } .:53 { forward . 8.8.8.8 8.8.4.4 log }
-
Configure your router to use this VM's IP address as the primary DNS server.
-
Create a new VM to act as your reverse proxy.
-
Install NGINX on this VM.
-
Configure NGINX as a reverse proxy:
http { server { listen 80; server_name *.xyz.local; return 301 https://$host$request_uri; } server { listen 443 ssl; server_name app1.xyz.local; ssl_certificate /path/to/app1.xyz.local.crt; ssl_certificate_key /path/to/app1.xyz.local.key; location / { proxy_pass http://192.168.1.101; } } # Repeat for other apps... }
-
Create a new VM to act as your Certificate Authority (CA).
-
Install Smallstep/certificates on this VM.
-
Initialize the CA:
step ca init --name "Local CA" --dns ca.xyz.local --address :443
-
Configure the CA for long-lived certificates:
{ "claims": { "minTLSCertDuration": "5s", "maxTLSCertDuration": "8760h", "defaultTLSCertDuration": "8760h" } }
-
Generate certificates for each domain:
step ca certificate app1.xyz.local app1.xyz.local.crt app1.xyz.local.key
-
Copy the certificates to your NGINX VM.
- Export the root certificate from your CA VM.
- Import the root certificate into the trust store of each client device.
- Ensure all client devices are using your CoreDNS server for DNS resolution.
- Import the root CA certificate into each client device's trust store.
Now, when you access https://app1.xyz.local from a client device on your network, it should:
- Resolve to your NGINX VM's IP address
- Connect securely using the custom certificate
- Be proxied to the correct application VM
Remember to keep your CA and certificates secure, and renew certificates before they expire.