【问题标题】:nginx proxy_pass to external url failnginx proxy_pass 到外部 url 失败
【发布时间】:2020-04-21 11:12:55
【问题描述】:

我想将 nginx 配置为代理_将我的域 *xyz.abc.com 传递到外部 url,例如 google.com/...这个想法与 post 相同。但它不断在下面显示错误:

 [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/"

这是我的配置

 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;
    }
}

我的配置有问题吗?我正在使用 nginx 1.11.6

【问题讨论】:

标签: nginx reverse-proxy nginx-reverse-proxy


【解决方案1】:

作为@Richard 的建议,我在解决我的问题的位置上下文中设置了解析器。

  resolver 8.8.8.8;
  resolver_timeout 10s;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-08
    • 2020-06-09
    • 1970-01-01
    • 2019-01-22
    • 2023-03-08
    相关资源
    最近更新 更多