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.
On my local (Windows) machine, local host works normally on the https://localhost:5001/swagger/index.html.
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?
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.
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.
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.