Quantcast
Channel: Active questions tagged https - Stack Overflow
Viewing all articles
Browse latest Browse all 1516

Docker Container - No response on https port in Visual Studio 2022 Debug build

$
0
0

i am trying to move an aspnet core application to docker.Unfortunately i can't get the application run on port https 8081.I tried several things (see my config below) but when trying to open the app via https in the browser nothing happens (i don't even see an error in the container log files).

enter image description here

I managed to get the app working on http with port 8080 but not on https

Here are my configs so far:

Dockerfile:

I installed additional packages like curl to be able to get more details on running processes and internal http requests on port 8081.

#how to use the asp.net image as baseFROM mcr.microsoft.com/dotnet/aspnet:8.0 AS baseUSER appWORKDIR /appEXPOSE 8081FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base#Install the .NET Core runtimeCOPY --from=mcr.microsoft.com/dotnet/sdk:8.0 /usr/share/dotnet/sdk /usr/share/dotnet/sdk# Instlling the required packagesRUN apt-get update && apt-get install -y procps telnet curl iproute2 wget

The certificate was made with openssl using the bash of the docker image and added to the kestrel config.

Kestrel Config:

"Kestrel": {"Endpoints": {"Https": {"Url": "https://localhost:8081","Certificate": {"Path": "/cert/localhost.crt","KeyPath": "/cert/localhost.key"      }    }  }}

My LaunchSettings in VisualStudio 2022 Version 17.11.0:

"SDir Docker": {"commandName": "Docker","launchBrowser": false,"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}","DockerfileRunArguments": "-p 5001:8081 -p 5000:8080 -v C:\\Users\\dumit\\.aspnet\\https\\:/cert:ro -v D:\\guis\\myservice2dev\\:/frontend:rw -v C:\\temp\\myservice\\database\\:/database:rw -v C:\\temp\\myservice\\plugins\\:/plugins:rw -v C:\\temp\\myservice\\logs\\:/logs:rw -v C:\\temp\\myservice\\secret\\:/secret:rw","environmentVariables": {"ASPNETCORE_ENVIRONMENT": "Development","ASPNETCORE_URLS": "https://+:8081;http://+:8080","ASPNETCORE_HTTPS_PORT": "8081","ASPNETCORE_HTTP_PORT": "8080"   } },

The docker-compose does not seem to have an effect, when starting the container in VS 2022 debug mode as it usese some sort of fast mode where lots of things are getting done automatically in the background.

docker-compose.yml:

services:  myservice:    build:      context: ../../../      dockerfile: MyServices/Backend/MyService/Dockerfile      args:        nuget_pat: ${AZURE_AUTH_TOKEN}    ports:      - "5001:8081"      - "5000:8080"    environment:      ASPNETCORE_ENVIRONMENT: Development      ASPNETCORE_HTTPS_PORT: "8081"      ASPNETCORE_HTTP_PORT: "8080"      ASPNETCORE_URLS: "https://+:8081;http://+:8080"      ASPNETCORE_Kestrel__Certificates__Default__Path: "/cert/localhost.crt"      ASPNETCORE_Kestrel__Certificates__Default__Password: "SomeFancyPassword"    volumes:      - ${APPDATA}\microsoft\UserSecrets\:/root/.microsoft/usersecrets      - ${USERPROFILE}\.aspnet\\https\\:/https:ro      - D:\\guis\\myService2dev\\:/frontend:rw      - C:\\temp\\myService\\database\\:/database:rw      - C:\\temp\\myService\\plugins\\:/plugins:rw      - C:\\temp\\myService\\logs\\:/logs:rw"

When the container is started the ports are configured to map 5001 -> 8081:

enter image description here

After the Docker image build i performed this steps in addition:

# Copy SSL certificates to the containercopied the localhost.crt to /usr/local/share/ca-certificates/# Update SSL certificates in the container bashupdate-ca-certificates

console output after update-ca-certificates

After enabling the certificates i finally got a reponse by using curl:

root@9d7ee1765902:/# curl https://localhost:8081<!doctype html><html lang="en" data-n-head="%7B%22lang%22:%7B%221%22:%22en%22%7D%7D"><head>    ...some more html here...<script src="/52c0694.js"></script><script src="/77b5243.js"></script></body></html>root@9d7ee1765902:/#

I already enabled the Logs in debug mode and get this output after the curl request:

dbug: Microsoft.Extensions.Hosting.Internal.Host[2]      Hosting startedApi interface started at https://+:8081info: Microsoft.Extensions.Hosting.BackgroundService[0]      Successfully started service MyServiceinfo: Microsoft.Hosting.Lifetime[0]      Application started. Press Ctrl+C to shut down.info: Microsoft.Hosting.Lifetime[0]      Hosting environment: Productioninfo: Microsoft.Hosting.Lifetime[0]      Content root path: /appdbug: Microsoft.Extensions.Hosting.Internal.Host[2]      Hosting starteddbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39]      Connection id "0HN5TPLCF9AQ9" accepted.dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1]      Connection id "0HN5TPLCF9AQ9" started.dbug: Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionMiddleware[3]      Connection 0HN5TPLCF9AQ9 established using the following protocol: Tls13info: Microsoft.AspNetCore.Hosting.Diagnostics[1]      Request starting HTTP/2 GET https://localhost:8081/ - - -dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0]      Wildcard detected, all requests with hosts will be allowed.info: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[2]      Sending file. Request path: '/index.html'. Physical path: '/frontend/index.html'dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6]      Connection id "0HN5TPLCF9AQ9" received FIN.dbug: Microsoft.AspNetCore.Server.Kestrel.Http2[48]      Connection id "0HN5TPLCF9AQ9" is closed. The last processed stream ID was 1.dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[8]      Connection id "0HN5TPLCF9AQ9" sending RST because: "The client closed the connection."info: Microsoft.AspNetCore.Hosting.Diagnostics[2]      Request finished HTTP/2 GET https://localhost:8081/index.html - 200 2450 text/html 65.1364msdbug: Microsoft.AspNetCore.Server.Kestrel.Http2[62]      The connection queue processing loop for 0HN5TPLCF9AQ9 completed.dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2]      Connection id "0HN5TPLCF9AQ9" stopped.

Does anyone has some additional ideas on how to troubleshoot this issue?

Regards meisterd


Viewing all articles
Browse latest Browse all 1516

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>