- 新增 proxy.h / proxy.c:路径前缀匹配 → HTTP/1.1 后端转发 - proxy_init/add_rule/match/forward API - X-Forwarded-For / X-Forwarded-Proto 透传 - 目前仅支持 HTTP 后端,HTTPS 后端拒绝并警告 - cocoon.h:新增 COCOON_MAX_PROXY_RULES=8,cocoon_config_t 添加 proxies 数组 - config.c:JSON 解析器新增 proxies 数组解析(prefix + target) - server.c: - connection_t 新增 ctx 指针,用于 handle_request 访问代理配置 - handle_request 中在静态文件服务前检查代理规则 - Makefile:proxy.c 加入 SRCS 和 test_server 编译规则 - cocoon.json:示例配置添加 proxies 数组 - tests/integration_test.sh:新增 3 项反向代理集成测试 - .cocoon-plan.md:标记反向代理为已完成 编译零警告,142 个单元测试 + 80 项集成测试全部通过。
17 lines
379 B
JSON
17 lines
379 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": "-",
|
|
"proxies": [
|
|
{"prefix": "/api", "target": "http://localhost:3000"}
|
|
]
|
|
}
|