Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!