nginx could not be resolved (3: Host not found)错误解决方案

在nginx的配置中将proxy_pass引用了变量,在Nginx0.6.18以后的版本都会有这样的错误,如果proxy_pass直接写地扯是没有问题的

错误配置如下

server {
  listen 80;
  server_name ~^(?<subdomain>.+)\.xxxx\.com$;
  location / {
    client_max_body_size    20m;
    proxy_pass http://$subdomain;
    proxy_set_header  Host  $host;
    proxy_set_header  X-Real-IP  $remote_addr;
    proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
  }
}

修正

server {
  listen 80;
  server_name ~^(?.+)\.issp\.bjike\.com$;
  location / {
    client_max_body_size    20m;
    resolver 8.8.8.8;//增加DNS解析地扯,局域网解析可设置自己的DNS解析服务器地扯,
    .....
  }
}

你可能感兴趣的:(nginx could not be resolved (3: Host not found)错误解决方案)