Nginx多个位置,第二个位置无法正确加载

时间:2019-05-14 07:20:37

标签: docker nginx nginx-location nginx-config

我有两个运行在端口5000和8080上的容器。 如果我将运行在端口8080上的容器放置在默认位置,则该页面将正确加载,但是当我将其放置在第二个位置时,该页面将无法正确加载。这是我配置nginx.config文件的方式:

events {}

http {
  server {
    listen 80;
    server_name localhost;

    location / { 
      proxy_pass "http://localhost:5000/";
    }

    location /home { 
      proxy_pass "http://localhost:8080/";
    }
  }
} 

页面显示如下:

enter image description here

这是在第二个位置设置时出现的:

enter image description here

编辑 我通过创建两个服务器来更新nginx.config,现在一切正常,但是是否可以让它在一台服务器上工作呢?

events {}

http {
  server {
    listen 80;
    server_name localhost;

    location / { 
      proxy_pass "http://localhost:5000/";
    }
  }

server {
    listen 80;
    server_name registry;

    location / { 
      proxy_pass "http://localhost:8080/";
    }
  }
}

0 个答案:

没有答案