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

No resolver defined to resolve #159

Closed
AlexProfi opened this issue Jan 23, 2019 · 2 comments

Comments

@AlexProfi
Copy link

commented Jan 23, 2019

Hello
I use redis in kubernetes cluster with nginx

My nginx lua config


  lua_package_path "/etc/nginx/lua-resty-redis/lib/?.lua;;";
  lua_shared_dict my_cache 10m;
  lua_shared_dict locks 1m;
  lua_shared_dict serials 1m;
  lua_socket_pool_size 300;

My code is

local ok, err = red:connect(os.getenv("REDIS_SVC_SERVICE_HOST"), os.getenv("REDIS_PORT"))
--Выводим адрес сервера редис 10.109.228.130
ngx.log(ngx.WARN, "REDIS server: ", os.getenv("REDIS_SVC_SERVICE_HOST"))

--Если РЕДИС не ответил вовремя то блокировка доступа (случается если не работает сервер редиса)
if not ok then
    ngx.log(ngx.ERR, "Failed to connect to REDIS server: ", err)
    ngx.exit(ngx.HTTP_FORBIDDEN)
end

And in logs I get strange errors

2019/01/23 10:46:36 [warn] 18#18: *438245 [lua] access.lua:23: REDIS server: 10.109.228.130, client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host:        "meteotravel.ru"
2019/01/23 10:46:36 [error] 18#18: *438245 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "", client: 192.168.1.252, server: meteotravel.   ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"

As you can see os.get_env return correct ip address
How to resolve it
And there are more errors

cat  default.error.log |grep error
2019/01/23 10:35:37 [error] 21#21: *44344 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
root@hb-node01:/var/log/nginx# vim default.error.log 
root@hb-node01:/var/log/nginx# cat  default.error.log |grep error
2019/01/23 10:35:37 [error] 21#21: *44344 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:43:07 [error] 18#18: *69796 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2�", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:43:31 [error] 26#26: *116465 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2��", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
root@hb-node01:/var/log/nginx# cat  default.error.log |grep error
2019/01/23 10:35:37 [error] 21#21: *44344 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:43:07 [error] 18#18: *69796 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2�", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:43:31 [error] 26#26: *116465 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2��", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:08 [error] 23#23: *177314 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:23 [error] 18#18: *208349 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2H", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:26 [error] 16#16: *208319 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2��", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
root@hb-node01:/var/log/nginx# cat  default.error.log |grep error
2019/01/23 10:35:37 [error] 21#21: *44344 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:43:07 [error] 18#18: *69796 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2�", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:43:31 [error] 26#26: *116465 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2��", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:08 [error] 23#23: *177314 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:23 [error] 18#18: *208349 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2H", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:26 [error] 16#16: *208319 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2��", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:38 [error] 26#26: *230636 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:44:48 [error] 23#23: *248883 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:45:33 [error] 25#25: *327722 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:45:56 [error] 24#24: *368955 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:46:09 [error] 22#22: *389003 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "10.109.2(", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:46:20 [error] 19#19: *409682 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"
2019/01/23 10:46:36 [error] 18#18: *438245 [lua] access.lua:27: Failed to connect to REDIS server: no resolver defined to resolve "", client: 192.168.1.252, server: meteotravel.ru, request: "GET / HTTP/1.0", host: "meteotravel.ru"

@agentzh

This comment has been minimized.

Copy link
Member

commented Feb 3, 2019

@AlexProfi You need to configure the resolver directive in your nginx.conf file:

http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver

The OpenResty's resolver directive also supports the local=on parameter which will read /etc/resolv.conf automatically. See this test case for examples:

https://github.com/openresty/openresty/blob/master/t/001-resolver.t#L20

@agentzh agentzh closed this Feb 3, 2019

@skwokie

This comment has been minimized.

Copy link

commented Apr 15, 2019

Hi,

I think it depends on the environment whether it requires to set the resolver or not. If running locally on my computer, then it doesn't. But when people run it in the cloud using some orchestration (I'm using AWS Fargate), then we may. Can you help by telling us when it is needed to specify a resolver?

Thanks,

skwok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.