环境:win11,docker 4.28.0 ,Net8 。使用windows版docker
跑老外的run-aspnetcore-microservices 这个分布式项目时,最开始直接运行会遇到这个问题。中间也试了几种方法,有ok也有不行的,有些较为麻烦。
Net8开始 Docker 端口 默认端口8080了
下面是我的
1 生成pfx文件 dotnet dev-certs https -ep %USERPROFILE%\.aspnet\https\aspnetapp.pfx -p 你的密码 dotnet dev-certs https --trust
2 docker-compose.yml 中添加 在以下位置添加 environment: - ASPNETCORE_Kestrel__Certificates__Default__Password=1236 #for windows 这里密码要写上,这里我是踏入坑了 - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx #for windows volumes: - ~/.aspnet/https:/https:ro #for windows
我的DockerCompose文件参考 environment: - ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_HTTP_PORTS=8080 - ASPNETCORE_HTTPS_PORTS=8081 - ApiSettings__GatewayAddress=http://yarpapigateway:8080 - ASPNETCORE_Kestrel__Certificates__Default__Password=1236 - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx depends_on: - yarpapigateway ports: - "6005:8080" - "6065:8081" volumes: - ${APPDATA}/Microsoft/UserSecrets:/home/app/.microsoft/usersecrets:ro # - ${APPDATA}/ASP.NET/Https:/home/app/.aspnet/https:ro - ~/.aspnet/https:/https:ro
如果不想 从http强制跳转到 https 注释代码中下面这句 app.UseHttpsRedirection();
效果图
标签:__,ASPNETCORE,https,Net8,Certificates,Docker,ro From: https://www.cnblogs.com/liujian1368928/p/18133200