Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
njjnjjnjj opened this issue Jan 21, 2025 · 1 comment
Open

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

njjnjjnjj opened this issue Jan 21, 2025 · 1 comment

Comments

@njjnjjnjj
Copy link

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 块 ,这个问题是否仅仅是 配置文件校验问题?

@njjnjjnjj njjnjjnjj changed the title nginx: [emerg] "nacos_subscribe_service" directive is not allowed here in /opt/nginx/conf/nginx.conf:20 在 stream 模块中无法使用 nacos_subscribe_service Jan 21, 2025
@zhwaaaaaa
Copy link
Collaborator

不支持 stream,仅 支持 http

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants