📚 Encyclopedia

Servers & Hosting · updated 2026-10-26

Hosting one static site per subdomain with a wildcard vhost

apachevirtualdocumentrootwildcard-dnsnginxcertbotlets-encryptstatic-hostingsecurity-headers

To give many users (or projects) each their own site at <slug>.example.com without writing a vhost per site, combine a wildcard DNS record, one Apache vhost using VirtualDocumentRoot, and a directory per slug. Each slug is then its own browser origin, which matters when the content is untrusted: one site's scripts cannot read another's cookies or storage. Used for the AI guest sites at *.ai.tldrcom.com (first one: aaron.ai.tldrcom.com), whose content is written by a sandboxed AI agent and must never execute on the server.

DNS

One wildcard A record, *.ai.tldrcom.com -> 45.79.9.71, covers every future slug; adding a site needs no DNS change. A wildcard matches only one label (a.ai.tldrcom.com, not b.a.ai.tldrcom.com).

Apache (behind nginx on :8008)

<VirtualHost *:8008>
    ServerName ai.tldrcom.com
    ServerAlias *.ai.tldrcom.com
    UseCanonicalName Off
    VirtualDocumentRoot /var/www/html/ai-guest/%1
    <Directory /var/www/html/ai-guest>
        Options +Indexes -ExecCGI -Includes -FollowSymLinks +SymLinksIfOwnerMatch
        AllowOverride None
        Require all granted
        AddType text/plain .php .phtml .phar .cgi .pl .py .sh
    </Directory>
    <Location "/">
        SetHandler none
    </Location>
    Header always set X-Content-Type-Options "nosniff"
    Header always unset Set-Cookie
</VirtualHost>

nginx and TLS

Publishing content

The content is produced elsewhere and pushed with rsync: rsync -rt --no-links --chmod=D755,F644 --delete public/ server:/var/www/html/ai-guest/<slug>/ then restorecon -R. --no-links keeps symlinks out; forced modes keep everything world-readable and nothing executable.

Gotchas

See also

Linked from

Sources: tldr memory (feature-ai-guest-mode), claude-service deploy/ai-guest/, global CLAUDE.md, tldr post #1822 (2026-10-22)