Skip to content

在 stream 模块中无法使用 nacos_subscribe_service #17

@njjnjjnjj

Description

@njjnjjnjj

nacos {
server_list x.x.x.x:8848; # nacos 服务器列表,空格隔开

# 如果 NACOS 1.x 使用 UDP 推送服务,可配置以下内容
udp_port 19999;             # udp 端口号
udp_ip x.x.x.x;           # udp ip 地址
udp_bind x.x.x..x:19999;     # 绑定udp地址

username "nacos";           # NACOS 认证用户名
password "nacos";    # NACOS 认证密码

error_log logs/nacos.log info; # 日志路径及级别
default_group DEFAULT_GROUP;   # 默认的 NACOS 组
cache_dir /opt/nginx/nacos_cache/; # 缓存目录,需确保nginx用户可写

}

stream {
upstream s {
# 通过 NACOS 动态订阅服务
nacos_subscribe_service service_name=service_name group=DEFAULT_GROUP;
hash $remote_addr; # 根据客户端 IP 地址进行哈希
}

server {
    listen 3306;  # 代理监听的端口
    proxy_pass s; # 转发到后端服务
}

}

请问支持 stream 模块使用动态订阅服务吗?使用以上配置文件抛出 nginx: [emerg] "nacos_subscribe_service" directive is not allowed here in /opt/nginx/conf/nginx.conf:20 错误,这个 nginx 服务器是用来做 tcp socket 服务的负载均衡的,用的并不是 http 块 ,这个问题是否仅仅是 配置文件校验问题?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions