在 192.168.65.5:53 上查找:没有这样的主机

时间:2021-03-25 17:20:02

标签: docker nginx

我尝试在 docker 中运行 nginx 并将其连接到 docker 中的一项服务。另一个服务在没有 docker 的情况下运行,也使用这个 nginx。我的 docker-compose:

version: "3.9"

services:
  nginx:
    restart: always
    image: nginx
    volumes:
      - ./config/nginx.conf:/etc/nginx/nginx.conf:ro
    ports:
      - "3000:80"
      - "9000:81"

  web:
    restart: always
    image: "xxxx/xxxx/web"

./config/nginx.conf 处的 nginx 配置:

events {}

http{
    upstream ws-api {
        server host.docker.internal:8081;
    }

    upstream ws-web {
        server web;
    }



    server {
        server_name localhost;
        listen      80;
     
        location / {
            include fastcgi_params;
            fastcgi_split_path_info ^(/)(.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_pass  ws-api;
        }
    }

    server {
        server_name localhost;
        listen      81;
     
        location / {
            include fastcgi_params;
            proxy_pass http://ws-web;
        }

        location /api {
            rewrite        ^([^.]*[^/])$ $1/;
            rewrite        ^/api(.*)$ $1 break;

            include fastcgi_params;
            fastcgi_split_path_info ^(/)(.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_pass  ws-api;
        }
    }
}

当我打开 localhost:9000 时,我收到错误消息:

<块引用>

在 192.168.65.5:53 上查找 ws-web:没有这样的主机

localhost:3000 工作正常

我的错误是什么?

1 个答案:

答案 0 :(得分:1)

将 Docker 更新到最新的 Apple Silicon Preview 版本为我解决了这个问题。

Here