Git Product home page Git Product logo

Comments (16)

xqpmjh avatar xqpmjh commented on July 30, 2024 1

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?

from lua-resty-dns.

agentzh avatar agentzh commented on July 30, 2024 1

I'm closing this.

from lua-resty-dns.

agentzh avatar agentzh commented on July 30, 2024

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

from lua-resty-dns.

gauravt avatar gauravt commented on July 30, 2024

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)?

from lua-resty-dns.

agentzh avatar agentzh commented on July 30, 2024

Hello!

On Tue, Apr 2, 2013 at 11:21 AM, gauravt [email protected] 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

from lua-resty-dns.

gauravt avatar gauravt commented on July 30, 2024

Thanks πŸ‘ Can we also use it to speed up our website?

from lua-resty-dns.

agentzh avatar agentzh commented on July 30, 2024

Hello!

On Tue, Apr 2, 2013 at 11:32 AM, gauravt [email protected] wrote:

Thanks [image: πŸ‘] Can we also use it to speed up our website?

It mostly depends on how you use it :)

from lua-resty-dns.

gauravt avatar gauravt commented on July 30, 2024

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

from lua-resty-dns.

oikomi avatar oikomi commented on July 30, 2024

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

from lua-resty-dns.

oikomi avatar oikomi commented on July 30, 2024

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

from lua-resty-dns.

agentzh avatar agentzh commented on July 30, 2024

@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.

from lua-resty-dns.

oikomi avatar oikomi commented on July 30, 2024

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

from lua-resty-dns.

agentzh avatar agentzh commented on July 30, 2024

@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.

from lua-resty-dns.

xqpmjh avatar xqpmjh commented on July 30, 2024

@agentzh clear, thank you very much!!

from lua-resty-dns.

gauravt avatar gauravt commented on July 30, 2024

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.

from lua-resty-dns.

agentzh avatar agentzh commented on July 30, 2024

@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.

from lua-resty-dns.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.