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

Usage #1

Closed
gauravt opened this issue Apr 2, 2013 · 16 comments
Closed

Usage #1

gauravt opened this issue Apr 2, 2013 · 16 comments

Comments

@gauravt
Copy link

gauravt commented Apr 2, 2013

I am using NGX_OPENRESTY server, can I use this module for DNS Lookup?

@agentzh
Copy link
Member

agentzh commented Apr 2, 2013

Sure. In fact this library is bundled and enabled by default in ngx_openresty, among other things :)

@gauravt
Copy link
Author

gauravt commented Apr 2, 2013

Great, I'm quite new to these stack can you tell me how I need to use it in ngx_openresty for my website's resources(DNS Requests)?

@agentzh
Copy link
Member

agentzh commented Apr 2, 2013

Hello!

On Tue, Apr 2, 2013 at 11:21 AM, gauravt notifications@github.com wrote:

Great, I'm quite new to these stack can you tell me how I need to use it
in ngx_openresty for my website's resources(DNS Requests)?

By means of the ngx_lua module:

http://wiki.nginx.org/HttpLuaModule

-agentzh

@gauravt
Copy link
Author

gauravt commented Apr 2, 2013

Thanks 👍 Can we also use it to speed up our website?

@agentzh
Copy link
Member

agentzh commented Apr 2, 2013

Hello!

On Tue, Apr 2, 2013 at 11:32 AM, gauravt notifications@github.com wrote:

Thanks [image: 👍] Can we also use it to speed up our website?

It mostly depends on how you use it :)

@gauravt
Copy link
Author

gauravt commented Apr 2, 2013

Can you give me any example to speed up a domain using lua-resty-dns?

@oikomi
Copy link

oikomi commented Jun 10, 2014

speed up a domain? you mean a dns local cache?

@oikomi
Copy link

oikomi commented Jun 10, 2014

@agentzh can add a feature to cache dns record using ngx-lua share Dict?

@agentzh
Copy link
Member

agentzh commented Jun 10, 2014

@oikomi Just to clarify:

  1. nginx's own resolver already has an rbtree-based cache, so use of lua-resty-dns will not outperform the builtin resolver. The lua-resty-dns library is just much more featureful and much more flexible.
  2. I'm not going to add a default caching layer to lua-resty-dns because I'd like to keep this driver minimal and it is always trivial to do caching on the user side or in a higher level wrapping Lua library. Also, there are various different caching solutions out there, like ngx.shared.DICT and lua-resty-lrucache.

@oikomi
Copy link

oikomi commented Jun 11, 2014

@agentzh I agree. Keep the project function minimization, Combined them.

@xqpmjh
Copy link

xqpmjh commented Jun 13, 2014

hi @agentzh, I have a question when recently playing ngx.socket.tcp. The problem is the host I set in /etc/hosts couldn't be used. But only native IP works. That means I have to parse /etc/hosts manually? Or if there is a module which do this job already?

@agentzh
Copy link
Member

agentzh commented Jun 15, 2014

@xqpmjh Right. Neither the nginx builtin resolver nor lua-resty-dns honor the /etc/hosts file (or its equivalent on other exotic systems). For now you have to parse /etc/hosts yourself if you want to support it.

@xqpmjh
Copy link

xqpmjh commented Jun 25, 2014

@agentzh clear, thank you very much!!

@gauravt
Copy link
Author

gauravt commented Jul 8, 2014

My problem is I need to fetch data from a website using a static ip means I have created a proxy in nginx which uses a domain+url-path but i need to use a static ip for it.
I am using Openresty with lua code in one web server and it proxy the requests to Amazon Elastic Load Balancer which doesn't provide a static ip, so is there a solution to resolve dns for elb and fetch data for the domain using returned IP.

@agentzh
Copy link
Member

agentzh commented Jul 8, 2014

@gauravt You're recommended to ask such general questions on the openresty-en mailing list where you're more likely to get answers: https://groups.google.com/group/openresty-en Thank you for your collaborations!

Regarding your question, you can use the nginx's own dynamic resolver to do the magic for you. For example,

location / {
    resolver 8.8.8.8;    # here we use Google's open DNS server just as an example
    set $backend "my-aws-load-balancer-dns-name";
    proxy_pass http://$backend;
}

Use of nginx variables in proxy_pass will make nginx resolve the DNS name nonblockingly on the fly and cache the resolved IP addresses automatically according to the TTL setting in the DNS records.

@agentzh
Copy link
Member

agentzh commented Jul 19, 2014

I'm closing this.

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

4 participants