Virtual hosts
Use [domain] sections to run multiple sites in one paozhu process.
Example config
[default]
mainhost = www.example.com
wwwpath = ./www/default
httpport = 80
httpsport = 443
global_http2_enable = 1
[www.example.com]
wwwpath = ./www/default
http2_enable = 1
acme_auto = 1
[api.example.com]
wwwpath = ./www/api
http2_enable = 1
[shop.example.com]
wwwpath = ./www/shop
httpport = 8080[default] is the fallback site; every other section name is a site identifier. Requests are matched exactly against the Host header and fall back to index 0 ([default]) when there is no hit.
What a site section can override
A site section can override wwwpath, http2_enable, acme_auto, upload_max_size, siteid, groupid, alias_domain, cors_domain, static_pre, fastcgi_host / fastcgi_port, isuse_php and rewrite_404, among others.
www and non-www
When mainhost starts with www., the code derives a secondhost without the prefix and matches both. For identical content, the safest approach is to point both site sections at the same wwwpath.
Certificates and SNI
conf/www.example.com.pem # fullchain
conf/www.example.com.key # private key
conf/www.example.com.crt # leaf certificate
conf/dh4096.pem # DH parameters
# SNI lookup falls back between www.example.com and example.com.Each virtual site looks up .pem / .key / .crt by domain. A www. domain falls back to the bare domain and vice versa. During the TLS handshake, SNI switches to the matching SSL_CTX.
Test locally
# /etc/hosts (local test only)
127.0.0.1 www.example.com api.example.com shop.example.comBind hosts
Point test domains to
127.0.0.1.Create roots
Make sure every
wwwpathdirectory exists and is readable.Start the server
./bin/paozhu conf/server.conf.Visit each host
http://www.example.com/,http://api.example.com/,http://shop.example.com/.Check Host matching
Use
curl -H "Host: api.example.com" http://127.0.0.1/to verify routing.