Docker: proxy_pass to another container - nginx: host not found in upstream

前端 未结 4 871
我在风中等你
我在风中等你 2021-01-12 04:18

(I know others have asked this question before, but I\'m not able to solve the problem using the solutions proposed in other posts, so i figured i would try to post my c

4条回答
  •  北海茫月
    2021-01-12 04:59

    Hello your problem is with the port when you linked web:web you need to specify the port in which the container runs the service for exemple

        ports:
      - "8000:80"
    

    means inside the container i can access on port 80 but in the host machine i can acess via 8000. here's the doc about linking two services in docker-compose

    so if you want to access web in proxy nginx don't use 8000 but use :

    upstream docker-web {
    server web:80;
      }
    

    instead, this should work :)

    or (those are both the same)

     upstream docker-web {
        server web;
          }
    

提交回复
热议问题