V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
fighterhit
V2EX  ›  问与答

Nginx 默认 dns 解析缓存有效期是多少呢?

  •  
  •   fighterhit · Nov 30, 2022 · 1189 views
    This topic created in 1257 days ago, the information mentioned may be changed or developed.
    看文档上面没说,代码里面没找到有常量定义,有大佬了解吗?
    http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver
    6 replies    2022-12-03 21:38:05 +08:00
    XIU2
        1
    XIU2  
       Nov 30, 2022
    我记得是 Nginx 启动时会对域名进行 DNS 解析,然后就一直使用得到的 IP 地址,直到重载或重启 Nginx 。
    blackeeper
        2
    blackeeper  
       Nov 30, 2022
    官方不是有么 [valid=time],可以自定义
    Syntax: resolver address ... [valid=time] [ipv4=on|off] [ipv6=on|off] [status_zone=zone];
    Default: —
    Context: http, server, location
    fighterhit
        3
    fighterhit  
    OP
       Dec 1, 2022
    @blackeeper 嗯,想知道没定义的情况下默认是多少
    fighterhit
        4
    fighterhit  
    OP
       Dec 1, 2022
    @XIU2 嗯,发现后端 k8s service 没了,nginx dns 解析 service name 还是到老的 clusterIP
    blackeeper
        5
    blackeeper  
       Dec 2, 2022
    官方文档,默认就是 TTL 值,1.1.9 之前的版本 5 分钟

    By default, nginx caches answers using the TTL value of a response. An optional valid parameter allows overriding it:

    resolver 127.0.0.1 [::1]:5353 valid=30s;
    Before version 1.1.9, tuning of caching time was not possible, and nginx always cached answers for the duration of 5 minutes.
    @fighterhit
    fighterhit
        6
    fighterhit  
    OP
       Dec 3, 2022
    @blackeeper 嗯这个看到过,1.1.9 太早了,现在默认多少呢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3001 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 08:35 · PVG 16:35 · LAX 01:35 · JFK 04:35
    ♥ Do have faith in what you're doing.