cocoon/cocoon.json
xfy911 60ef9ed908 feat(vhost): 虚拟主机/多站点支持
- cocoon.h: 新增 cocoon_vhost_t 结构体和 COCOON_MAX_VHOSTS 宏
- config.c: JSON 解析器新增 vhosts 数组解析
- server.c: HTTP/1.1 请求根据 Host 头匹配虚拟主机 root_dir
- http2.h/c: HTTP/2 根据 :authority 匹配虚拟主机,存储为 Host 头
- http2.c: 新增 http2_session_set_server_config() API
- cocoon.json: 添加 vhosts 配置示例
- tests: 新增 3 项虚拟主机集成测试
- 编译零警告,142 单元测试 + 106 集成测试全部通过
2026-06-09 15:28:57 +08:00

23 lines
749 B
JSON

{
"root_dir": "./examples/www",
"port": 8080,
"threaded": true,
"num_workers": 4,
"max_connections": 10000,
"timeout_ms": 30000,
"log_level": "info",
"gzip_enabled": true,
"brotli_enabled": true,
"plugins": ["plugins/hello.so"],
"access_log": "-",
"vhosts": [
{"server_name": "site-a.local", "root_dir": "./examples/www_a"},
{"server_name": "site-b.local", "root_dir": "./examples/www_b"}
],
"proxies": [
{"prefix": "/api", "target": "http://localhost:3000", "pool_size": 8, "weight": 3},
{"prefix": "/api", "target": "http://localhost:3001", "weight": 1},
{"prefix": "/backend", "target": "https://localhost:8443", "pool_size": 4, "weight": 1}
]
}