0

I'd like to config nginx to proxy_pass my domain *xyz.abc.com to external url such as google.com/...The idea is same as this post. But it constantly show error below:

 [error] 12725#12725: *1530410 no resolver defined to resolve google.com, client: 27.64.99.7, server: ~^(?<name>\w+)\.xyz\.abc\.com$, request: "GET /favicon.ico HTTP/1.1", host: "ivy1.xyz.abc.com", referrer: "http://ivy1.xyz.abc.com/"

Here is my config

 server {
    server_name ~^(?<name>\w+)\.xyz\.abc\.com$;
    location / {

      proxy_pass https://google.com/$name$request_uri;
      proxy_set_header Host $proxy_host;
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Is the something wrong in my configuration? I'm using nginx 1.11.6

Tien Dung Tran
  • 1,127
  • 4
  • 16
  • 32
  • You need to define a `resolver`. See [this document](http://nginx.org/en/docs/http/ngx_http_core_module.html#resolver). – Richard Smith Apr 20 '20 at 10:49

1 Answers1

0

As @Richard advice,I set resolver in location context which solved my issue.

  resolver 8.8.8.8;
  resolver_timeout 10s;
Tien Dung Tran
  • 1,127
  • 4
  • 16
  • 32