我真的很挣扎。在我开始之前,一切都适用于不安全的 http
连接。但我想要/需要一个安全的 https
连接。所以我加了
app.UseHttpsRedirection();
在我的 Startup.cs
文件中的 Configure
部分。
本地windows机器
在我的本地 (Windows) 机器上,本地主机在 https://localhost:5001/swagger/index.html
上正常工作。
服务器
在我的服务器 (Ubuntu 20.04) 机器上,本地主机几乎按预期工作。链接 https://localhost:5001/swagger/index.html
有效,但连接不安全。为什么?
服务器上的 Docker
当使用 Docker 运行时
#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"]
和
docker run --name backend --mount type=bind,source=/home/mjancic/Documents/Data,target=/Data -p
8082:443 metuljmania/dockerapi
我明白
ERR_SSL_PROTOCOL_ERROR
尝试从外部连接时。
嗯...
我不明白。怎么解决这个问题。我不明白我做错了什么,这真的不应该那么困难。
预期行为
通过 Docker 的安全连接。或者实际上,在这一点上我什至不在乎它是否是 docker。我只想安全连接到我的 API。