We have a simple web project built using .Net 8.0 and using Docker. We have made no changes to the default Dockerfile that Visual Studio created
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080
EXPOSE 8081
When we run this in Docker Desktop we can see it logs two entries
Now listening on: http://[::]:8080
Now listening on: https://[::]:8081
When deployed to ECS (Fargate) it only ever listens on http://[::]8080 and not https.
Does anyone know why?
Wanted to post an update as I have managed to solve it and it may help others.
When running the project from Visual Studio, the magic behind the scenes creates the developer self signed certificates and injects them into the kestrel web server.
When running in production this does not happen so you need to manually add the certificates. Ideally you should use production SSL certificates that are fully valid but in my case for AWS I could not as these were bound to the load balancers and not exportable.
What I did was:
ASPNETCORE_HTTPS_PORTS=8081 ASPNETCORE_Kestrel__Certificates__Default__Password=mycertificatepassword ASPNETCORE_Kestrel__Certificates__Default__Path=/app/Certificates/ProductionCertificate.pfx