mybirthname
mybirthname

Reputation: 18127

Docker returning response only for http port

Here is the part of the docker compose

ecommerce.supplier:
    container_name: supplier
    image: ${DOCKER_REGISTRY-}ecommercesupplier
    build:
        context: .
        dockerfile: ECommerce.Supplier/Dockerfile
    ports:
        - "5000:80"
        - "5001:443"
    env_file: ECommerce.Common/Common.env
    environment:
        - ConnectionStrings__DefaultConnection=Server=host.docker.internal\MSSQLSERVER01;Database=ECommerceSupplier;User Id=sa;Password=123456;MultipleActiveResultSets=true
    restart: on-failure
    volumes:
        - ./.aspnet/supplier/DataProtection-Keys:/root/.aspnet/DataProtection-Keys
    networks: 
        - ecommerce-network

Here is part of the Docker file for this service which exposes the ports. The file is auto generated by visual studio.

FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

Here is docker ps:

enter image description here

So what is the result of all of this. When I hit http://localhost:5000/api/V1/Supplier/getlist with get request with proper token I receive a response. But if I try with same end point with https://localhost:5001 I receive "Could not get any response" in postman.

How I can make it work on https://localhost:5001. My level in dev ops is beginner, so if you want additional information please consider to explain carefully what exactly you need.

Side note this is happening for the all services in the screenshot.

Upvotes: 1

Views: 1800

Answers (1)

ddfra
ddfra

Reputation: 2565

It looks like the problem is that, inside your docker container, the application is not listening on 443.

Maybe these two links may help you:

I would give a look at this part:

version: '3.4'

services:
  webapp:
    image: mcr.microsoft.com/dotnet/core/samples:aspnetapp
    ports:
      - 80
      - 443
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
      - ASPNETCORE_Kestrel__Certificates__Default__Password=password
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    volumes:
      - ~/.aspnet/https:/https:ro

at the environment.ASPNETCORE_URLS property.

Hope this is helpful.

Upvotes: 2

Related Questions