
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Nginx Push Stream Module是一个为Nginx设计的纯流HTTP推送技术模块,旨在简化Comet(一种用于实现Web实时通信的技术)的实现并提供高度可扩展性。该模块不随Nginx源码分发,需单独安装,目前已被认为是生产就绪的稳定模块。
在Nginx配置文件中添加以下内容以启用模块功能:
nginx# 在http上下文中配置共享内存大小 http { push_stream_shared_memory_size 32M; # 设置推送流共享内存大小 # 在server上下文中定义发布者、订阅者和统计端点 server { # 频道统计端点 location /channels-stats { push_stream_channels_statistics; # 启用频道统计模式 push_stream_channels_path $arg_id; # 基于查询字符串的频道ID } # 发布者端点 location /pub { push_stream_publisher admin; # 启用发布者(管理员)模式 push_stream_channels_path $arg_id; # 基于查询字符串的频道ID } # 订阅者端点(通过URL路径匹配频道ID) location ~ /sub/(.*) { push_stream_subscriber; # 启用订阅者(流)模式 push_stream_channels_path $1; # 基于URL路径的频道ID(捕获组匹配) } } }
通过命令行工具(如curl)即可体验模块的核心功能,建议使用多个终端分别执行发布和订阅操作:
bash# 订阅频道"my_channel_1" curl -s -v --no-buffer 'http://localhost/sub/my_channel_1' # 订阅频道"your_channel_1" curl -s -v --no-buffer 'http://localhost/sub/your_channel_1' # 订阅频道"your_channel_2" curl -s -v --no-buffer 'http://localhost/sub/your_channel_2'
bash# 向"my_channel_1"发布消息 curl -s -v -X POST 'http://localhost/pub?id=my_channel_1' -d 'Hello World!' # 向"your_channel_1"发布消息 curl -s -v -X POST 'http://localhost/pub?id=your_channel_1' -d 'Hi everybody!' # 向"your_channel_2"发布消息 curl -s -v -X POST 'http://localhost/pub?id=your_channel_2' -d 'Goodbye!'
bash# 获取指定频道信息(如"my_channel_1") curl -s -v 'http://localhost/pub?id=my_channel_1' # 获取所有频道汇总统计 curl -s -v 'http://localhost/channels-stats' # 获取所有频道详细统计 curl -s -v 'http://localhost/channels-stats?id=ALL' # 获取前缀匹配的频道详细统计(如"your_channel_"开头的所有频道) curl -s -v 'http://localhost/channels-stats?id=your_channel_*' # 获取单个频道详细统计(如"my_channel_1") curl -s -v 'http://localhost/channels-stats?id=my_channel_1'
bash# 删除指定频道(如"my_channel_1") curl -s -v -X DELETE 'http://localhost/pub?id=my_channel_1'
模块提供多种集成示例,包括:
使用中遇到问题,请查阅项目https://github.com/wandenberg/nginx-push-stream-module/wiki/_pages%E3%80%82
bash# 克隆项目仓库 git clone https://github.com/wandenberg/nginx-push-stream-module.git NGINX_PUSH_STREAM_MODULE_PATH=$PWD/nginx-push-stream-module # 下载Nginx源码(1.2.0或更高版本) wget http://nginx.org/download/nginx-1.2.0.tar.gz # 解压并编译Nginx(添加模块) tar xzvf nginx-1.2.0.tar.gz cd nginx-1.2.0 ./configure --add-module=../nginx-push-stream-module # 添加推送流模块 make # 安装Nginx sudo make install # 验证安装版本 sudo /usr/local/nginx/sbin/nginx -v # 预期输出:nginx version: nginx/1.2.0 # 测试配置文件 sudo /usr/local/nginx/sbin/nginx -c $NGINX_PUSH_STREAM_MODULE_PATH/misc/nginx.conf -t # 预期输出配置语法检查通过 # 启动Nginx(使用模块示例配置) sudo /usr/local/nginx/sbin/nginx -c $NGINX_PUSH_STREAM_MODULE_PATH/misc/nginx.conf
模块各组件的最小内存占用:
以下是模块核心指令及其适用的配置上下文((1)定义位置、(2)主要配置、(3)订阅者配置、(4)发布者配置、(5)频道统计配置、(6)WebSocket配置):
| 指令 | (1) | (2) | (3) | (4) | (5) | (6) |
|---|---|---|---|---|---|---|
| push_stream_channels_statistics | x | - | - | - | - | - |
| push_stream_publisher | x | - | - | - | - | - |
| push_stream_subscriber | x | - | - | - | - | - |
| push_stream_shared_memory_size | - | x | - | - | - | - |
| push_stream_channel_deleted_message_text | - | x | - | - | - | - |
| push_stream_channel_inactivity_time | - | x | - | - | - | - |
| push_stream_ping_message_text | - | x | - | - | - | - |
| push_stream_timeout_with_body | - | x | - | - | - | - |
| push_stream_message_ttl | - | x | - | - | - | - |
| push_stream_max_subscribers_per_channel | - | x | - | - | - | - |
| push_stream_max_messages_stored_per_channel | - | x | - | - | - | - |
| push_stream_max_channel_id_length | - | x | - | - | - | - |
| push_stream_max_number_of_channels | - | x | - | - | - | - |
| push_stream_max_number_of_wildcard_channels | - | x | - | - | - | - |
| push_stream_wildcard_channel_prefix | - | x | - | - | - | - |
| push_stream_events_channel_id | - | x | - | - | - | - |
| push_stream_channels_path | - | - | x | x | x | x |
| push_stream_store_messages | - | - | - | x | - | x |
| push_stream_channel_info_on_publish | - | - | - | x | - | - |
| push_stream_authorized_channels_only | - | - | x | - | - | x |
| push_stream_header_template_file | - | - | x | - | - | x |
| push_stream_header_template | - | - | x | - | - | x |
| push_stream_message_template | - | - | x | - | - | x |
| push_stream_footer_template | - | - | x | - | - | x |
| push_stream_wildcard_channel_max_qtd | - | - | x | - | - | x |
| push_stream_ping_message_interval | - | - | x | - | - | x |
| push_stream_subscriber_connection_ttl | - | - | x | - | - | x |
| push_stream_longpolling_connection_ttl | - | - | x | - | - | - |
| push_stream_websocket_allow_publish | - | - | - | - | - | x |
| push_stream_last_received_message_time | - | - | x | - | - | - |
| push_stream_last_received_message_tag | - | - | x | - | - | - |
| push_stream_last_event_id | - | - | x | - | - | - |
| push_stream_user_agent | - | - | x | - | - | - |
| push_stream_padding_by_user_agent | - | - | x | - | - | - |
| push_stream_allowed_origins | - | - | x | - | - | - |
| push_stream_allow_connections_to_events_channel | - | - | x | - | - | x |
模块的服务器测试使用Ruby编写,采用验收测试框架,详细测试说明参见测试文档。
该模块已达到生产就绪状态,稳定用于各类实时推送场景。项目讨论可通过Nginx Push Stream Module讨论组进行。
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。

来自真实用户的反馈,见证轩辕镜像的优质服务