Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

224
Visualizações
Running .net api inside docker with secure connection does not work

I am really struggling with this. Before I start, everything works on the unsecure http connection. But I want/need a secure https connection. So I added

app.UseHttpsRedirection();

in my Startup.cs file in the Configure section.

Local windows machine

On my local (Windows) machine, local host works normally on the https://localhost:5001/swagger/index.html.

Server

On my server (Ubuntu 20.04) machine, local host works almost as expected. The link https://localhost:5001/swagger/index.html works but the connection is not secure. Why?

Docker on server

When running from Docker using the

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
RUN sed -i'.bak' 's/$/ contrib/' /etc/apt/sources.list
RUN apt-get update; apt-get install -y ttf-mscorefonts-installer fontconfig
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build
WORKDIR /src
COPY ["MetuljmaniaDatabase.csproj", "."]
RUN dotnet restore "./MetuljmaniaDatabase.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "MetuljmaniaDatabase.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MetuljmaniaDatabase.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
EXPOSE 80
COPY --from=publish /app/publish .
ENV ASPNETCORE_ENVIRONMENT="Development"
ENTRYPOINT ["dotnet", "MetuljmaniaDatabase.dll"]

and

docker run --name backend --mount type=bind,source=/home/mjancic/Documents/Data,target=/Data -p 
8082:443 metuljmania/dockerapi

I get

ERR_SSL_PROTOCOL_ERROR

when trying to connect to it from the outside.

Ehm ...

I don't get it. How do fix this. I don't get what I am doing wrong, this really isn't supposed to be that difficult.

Expected behaviour

Secure connection via Docker. Or actually, at this point I don't even care if it's docker. I just want a secure connection to my API.

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda