Pcornel
Web Infrastructure · Web Services

Virtual Hosts

Cheat sheet · https://pcornel.dk/topic.php?topic=2877

Back to the Topic

Answer

Virtual hosts let one web server serve several sites, selected by host name (Host header and TLS SNI), IP address or port.

Remember

If no virtual host matches the name, the default (first or explicitly marked) answers — often showing another site. Each HTTPS site needs a certificate matching its name (SNI).

First checks

  • systemctl status nginx|apache2|httpd — web server state
  • nginx -t / apachectl configtest — configuration test
  • ss -ltnp | grep -E ':80|:443' — listening ports
  • curl -vI https://<name> — response, headers and TLS
  • tail -f /var/log/nginx/error.log — error log (or apache2/httpd)

Verify in this order

client sends Host/SNI → server matches a virtual host → serves its content and certificate

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2877

Confirmation

Confirm action

Continue?