nginx中的解析器参数做什么? [英] What does the Resolver param in nginx do?

查看:82
本文介绍了nginx中的解析器参数做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将nginx用作ELB的反向代理服务器.我正在寻找有关我在nginx.conf文件中设置的解析器值的说明.我的nginx.conf:

I am using nginx as a reverse_proxy server with ELB. I am looking for explanation regarding the resolver value I set in the nginx.conf file. My nginx.conf:

http {  
   ...

   resolver x.x.x.x valid=30s;

   ...
}

server {

   ...

   set $elb "example.com";

location / { 
    ...

    rewrite ^/(.*) $1 break;
    proxy_pass http://$elb/$1?$args; 

    ...
   }
   ...    
}  

我遵循了此- https://www.ruby-forum.com/topic /6816375#1166569 并将/etc/resolv.conf值设置为解析程序值,它可以正常工作.这背后是什么?

I followed this - https://www.ruby-forum.com/topic/6816375#1166569 and set /etc/resolv.conf value as the resolver value and it works fine. What is standing behind this?

推荐答案

由于系统解析器受阻,因此需要nginx解析器指令. Nginx是一个多路复用服务器(在一个OS进程中有许多连接),因此系统解析器的每次调用将停止处理所有连接,直到收到解析器应答为止.这就是Nginx实现其内部非阻塞解析器的原因.

The nginx resolver directive is required because the system resolver blocks. Nginx is a multiplexing server (many connections in one OS process), so each call of system resolver will stop processing all connections till the resolver answer is received. That's why Nginx implemented its own internal non-blocking resolver.

如果您的配置文件具有静态DNS名称(未生成),并且您不关心在没有重新加载nginx的情况下跟踪IP的更改,则不需要nginx的解析器.在这种情况下,所有DNS名称都将在启动时解析.

If your config file has static DNS names (not generated), and you do not care about track IP changes without nginx reload, you don't need nginx's resolver. In this case all DNS names will be resolved on startup.

如果要在运行时解析域名而无需重新加载nginx,则应使用Nginx的resolver.

Nginx's resolver should be used, if you want to resolve domain name in runtime without nginx reload.

这篇关于nginx中的解析器参数做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆