簡體   English   中英

Azure web app multi container (MEAN app),從前端容器連接到節點后端容器的URL是什么?

[英]Azure web app multi container (MEAN app), what is the URL to connect to node backend container from front end container?

Trying to learn to deploy angular app to azure web app using multi-container, the frontend loads fine but cant connect to the backend node container, I want to add the url of the node backend to my angular frontend but i cant figure out what it是。 I've tried https://rojesh.azure.io:3000 , https://rojesh.azurewebsites.net:3000 , http://server:3000 and more but nothing seems to work. 網站主機名: https://rojesh.azurewebsites.net,acr名稱為 rojesh.azurecr.io,其中包含 3 個圖像。 這是我在 azure 中撰寫的配置文件:

version: '3.3'

services:
    db:
      image: rojesh.azurecr.io/db:latest
      ports:
        - "27017:27017"
      restart: always
      networks:
        - app-network

    server:
      image: rojesh.azurecr.io/server:latest
      depends_on:
        - db
      ports:
        - "3000:3000"
      restart: always
      networks:
        - app-network

    app:
      depends_on:
        - server
      image: rojesh.azurecr.io/app:latest
      environment:
        NGINX_HOST: rojesh.azurewebsites.net
        NGINX_PORT: 80
      ports:
        - "80:80"
      restart: always
      networks:
        - app-network

networks:
  app-network:
    driver: bridge 

該應用程序使用 docker compose 在本地運行良好,即:

version: '3.9'

services:
  docker-app:
    build:
      context: app 
      dockerfile: Dockerfile.dev
    ports:
      - '4200:4200'
    volumes:
      - ./app/src:/app/src 
      

  docker-server:
    build:
      context: server
      dockerfile: Dockerfile
    environment: 
      PORT: 3000
      MONGODB_URI: mongodb://mongo:27017/rojesh
      JWT_SECRET: secret
    ports:
      - 3000:3000
    depends_on: 
      - mongo
    volumes:
      - ./server:/server

  mongo:
    container_name: mongo-server
    image: mongo:latest
    ports:
      - 27017:27017
  
    

謝謝@ ajkuma-msft Azure App Service 僅公開端口80443 是的,來自客戶端的傳入請求將超過443/80 ,應該映射到容器的暴露端口
應用服務將嘗試檢測將哪個端口綁定到您的容器。 如果您想將WEBSITES_PORT應用程序設置綁定到您的容器,並使用端口值對其進行配置。

Web App for Containers 目前只允許您向外界公開一個端口 容器只能在單個端口上偵聽 HTTP 請求。

從 Docker 組成配置的角度來看: 808080以外的端口被忽略。

請參閱Docker Compose 選項列表顯示支持不支持的 Docker Compose 配置選項。

參考這里

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM