Fitness Freak
Fitness Freak

Reputation: 11

How to Containerize .NET framework 4.7.8 http and https connection with ssl enabled, windows container

I'm trying to containerize the .NET framework4.7.8v which is a older version and it is supported only on windows container, Image got build with the respected base image and container is up and running, initially the source code web.config contains "https redirections" so after removing that , I can able to access the web page for "http" and not accessible on "https" , so for this https redirection will be their and anyhow the ssl is enabled on web.config file, so I have imported the ssl certificate .pfx file on root directory and copied that on container as well , and ensure its loaded and ssl flag was set to "1" even though I can able to access the web app with https connection.

Dockerfile:

# Use the official Microsoft ASP.NET image from the Docker Hub  
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019  

# Install additional dependencies  
RUN powershell -Command \
    Install-WindowsFeature NET-Framework-45-ASPNET; \
    Install-WindowsFeature Web-Asp-Net45  

    ADD https://download.microsoft.com/download/D/8/1/D81E5DD6-1ABB-46B0-9B4B-21894E18B77F/rewrite_x86_en-US.msi C:\\temp\\rewrite_x86_en-US.msi
RUN powershell -Command \
    Start-Process -Wait -FilePath "C:\\temp\\rewrite_x86_en-US.msi" -ArgumentList "/quiet"

# Set the working directory in the container  
WORKDIR /inetpub/wwwroot  

# Copy the published application files to the container  
COPY . .  
# Copy SSL/TLS certificate to the container  
COPY localhost.pfx /inetpub/wwwroot/localhost.pfx  

# Set the password as an environment variable  
ENV CERT_PASSWORD=*******  

# Import the SSL certificate  
RUN powershell -Command ' $SecurePassword=ConvertTo-SecureString -String $env:CERT_PASSWORD -AsPlainText -Force; Import-PfxCertificate -FilePath ''C:\inetpub\wwwroot\localhost.pfx'' -CertStoreLocation Cert:\LocalMachine\My -Password $SecurePassword '


# Expose port 44349 for HTTPS  
EXPOSE 80 443

# Define the entry point for the container  
ENTRYPOINT ["C:\\ServiceMonitor.exe", "w3svc"]

even I tried with Docker-compose file for that also I can't able to access the web page

Upvotes: 1

Views: 85

Answers (0)

Related Questions