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

consul 是 token 进行权限控制, 请支持 consul 的token #294

Open
zhouandke opened this issue Dec 25, 2020 · 1 comment
Open

consul 是 token 进行权限控制, 请支持 consul 的token #294

zhouandke opened this issue Dec 25, 2020 · 1 comment

Comments

@zhouandke
Copy link

如果consul开启了ACL, 就必须传入一个token 才能访问里面的数据

@zhushiyang
Copy link

zhushiyang commented Jul 22, 2022

代码地址:https://github.com/weibocom/nginx-upsync-module/blob/master/src/ngx_http_upsync_module.c

代码片段:包含【?recurse】

2702行:
{
ngx_sprintf(request, "GET %V?recurse&index=%uL HTTP/1.0\r\nHost: %V\r\n"
"Accept: */*\r\n\r\n",
&upscf->upsync_send, upsync_server->index,
&upscf->upsync_host);
}
 
3795行:
{
ngx_sprintf(request, "GET %V?recurse&index=%uL HTTP/1.0\r\nHost: %V\r\n"
"Accept: */*\r\n\r\n",
&upscf->upsync_send, upsync_server->index,
&upscf->[conf_server.name);](http://192.168.6.120:8090/pages/conf_server.name);)
}

解决办法:把?recurse删除掉,变成

2702行:
{
ngx_sprintf(request, "GET %V&index=%uL HTTP/1.0\r\nHost: %V\r\n"
"Accept: */*\r\n\r\n",
&upscf->upsync_send, upsync_server->index,
&upscf->upsync_host);
}
 
3795行:
{
ngx_sprintf(request, "GET %V&index=%uL HTTP/1.0\r\nHost: %V\r\n"
"Accept: */*\r\n\r\n",
&upscf->upsync_send, upsync_server->index,
&upscf->[conf_server.name);](http://192.168.6.120:8090/pages/conf_server.name);)
}

修改后,将模块编译到nginx中,在upstream中配置如下
Consul开启ACL
upsync domain:8500/v1/kv/upstreams/h5_shop?token=xxxxxxxxxxxxxxxxxxxxxxxxxx&recurse
Consul未开启ACL
upsync domain:8500/v1/kv/upstreams/h5_shop?recurse

已经测试过是OK的

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