Nginx解决“no resolver defined to resolve xxx.xxx”

简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
server {
     listen       80;
     server_name  *.b2b.sdy.com;
     
     location / {
         if ($host ~* (.*)\.b2b\.sdy\.com)       {
            set $company $1;
 
            proxy_pass http://www.baidu.com/$company;
         }
}
 
}

如果使用域名作为反向代理的地址的话会在Nginx0.6.18以后的版本中都会提示“ no resolver defined to resolve ”的类似错误,而在proxy_pass 中直接设置地址却不会。


原因是Nginx0.6.18以后的版本中启用了一个resolver指令,在使用变量来构造某个server地址的时候一定要用resolver指令来制定DNS服务器的地址,所以解决这个问题的方法很简单:


在nginx的配置文件中的http{}部分添加一行resolver 8.8.8.8;即可











本文转自 xinsir999 51CTO博客,原文链接:http://blog.51cto.com/xinsir/1541612,如需转载请自行联系原作者
目录
相关文章
|
3月前
|
网络协议 应用服务中间件 nginx
解决 nginx 启动错误host not found in upstream "XXXX.com“
在前置机上利用nginx进行反向代理的时候,我们会配置proxy_pass。在启动nginx的会报如下错误:host not found in upstream "XXXX.com“
535 0
|
2月前
|
应用服务中间件 网络安全 nginx
解决nginx:[emerg]unknown directive ssl错误
解决nginx:[emerg]unknown directive ssl错误
111 0
|
11月前
Error: undefined method `launchd_service_path‘ for xxx
使用brew命令进行启动就报错。
200 0
|
9月前
|
网络协议
出现“Could not resolve host: www.github.com; Unknown error”错误解决
出现“Could not resolve host: www.github.com; Unknown error”错误解决
387 0
|
Shell Go
goland 解决 cannot resolve directory 'xxxx'/ cannot resolve xxx 问题
goland 解决 cannot resolve directory 'xxxx'/ cannot resolve xxx 问题
goland 解决 cannot resolve directory 'xxxx'/ cannot resolve xxx 问题
|
应用服务中间件 nginx
【已解决】nginx: [warn] conflicting server name “www.xxx.com“ on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name “www.xxx.com“ on 0.0.0.0:443, ignored
484 0
|
JavaScript 前端开发
【build your own xxx】实现你自己的call和apply
【build your own xxx】实现你自己的call和apply
【build your own xxx】实现你自己的call和apply
|
SQL Java 数据库连接
Could not find resource xxx/xxxx/xxx.xml报错解决
Could not find resource xxx/xxxx/xxx.xml报错解决
Could not find resource xxx/xxxx/xxx.xml报错解决
|
Perl
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`. Y...
[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `cocoapods`. Y...
974 0
|
应用服务中间件 PHP nginx
nginx配置出错duplicate location “/”nginx: [emerg] duplicate location “/”
将nginx配置文件中的两个location合并成一个 就好了。 server { listen ******; listen *****; server_name ****; root /*****; location / { index index.
13018 0