简体   繁体   中英

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 is. I've tried https://rojesh.azure.io:3000 , https://rojesh.azurewebsites.net:3000 , http://server:3000 and more but nothing seems to work. Website Hostname: https://rojesh.azurewebsites.net and the acr name is rojesh.azurecr.io which has 3 images. This is my config file for compose in 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 

The app works fine locally using docker compose which is:

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
  
    

Thanks @ ajkuma-msft . Azure App Service only exposes ports 80 and 443 . Yes, incoming requests from client would just be over 443/80 which should be mapped to the exposed port of the container .
App Service will attempt to detect which port to bind to your container. If you want to bind to your container the WEBSITES_PORT app setting and configure it with a value of the port.

Web App for Containers currently allows you to expose only one port to the outside world. The container can only listen for HTTP requests on a single port.

From Docker compose configuration stand-point: Ports other than 80 and 8080 are ignored.

Refer Docker Compose options lists shows supported and unsupported Docker Compose configuration options.

Refer here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM