All Projects → kkoziarski → https-aspnetcore-in-docker

kkoziarski / https-aspnetcore-in-docker

Licence: other
ASP.NET Core app on HTTPS in Docker

Programming Languages

C#
18002 projects
powershell
5483 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to https-aspnetcore-in-docker

Lettuceencrypt
Free, automatic HTTPS certificate generation for ASP.NET Core web apps
Stars: ✭ 939 (+3812.5%)
Mutual labels:  aspnetcore, https
Devarchitecture
DevArchitecture Backend Project
Stars: ✭ 243 (+912.5%)
Mutual labels:  aspnetcore
Openiddict Samples
ASP.NET Core, Microsoft.Owin/ASP.NET 4.x and JavaScript samples for OpenIddict
Stars: ✭ 214 (+791.67%)
Mutual labels:  aspnetcore
Efcoresecondlevelcacheinterceptor
EF Core Second Level Cache Interceptor
Stars: ✭ 227 (+845.83%)
Mutual labels:  aspnetcore
Netdevpack
A smart set of common classes and implementations to improve your development productivity.
Stars: ✭ 220 (+816.67%)
Mutual labels:  aspnetcore
Aspnetcore.proxy
ASP.NET Core Proxies made easy.
Stars: ✭ 234 (+875%)
Mutual labels:  aspnetcore
Run Aspnetcore Realworld
E-Commerce real world example of run-aspnetcore ASP.NET Core web application. Implemented e-commerce domain with clean architecture for ASP.NET Core reference application, demonstrating a layered application architecture with DDD best practices. Download 100+ page eBook PDF from here ->
Stars: ✭ 208 (+766.67%)
Mutual labels:  aspnetcore
SharpPlugs
.Net Core 鋒利扩展
Stars: ✭ 26 (+8.33%)
Mutual labels:  aspnetcore
Blazortable
Blazor Table Component with Sorting, Paging and Filtering
Stars: ✭ 249 (+937.5%)
Mutual labels:  aspnetcore
Identityserver
An open-source, standards-compliant, and flexible OpenID Connect and OAuth 2.x framework for ASP.NET Core
Stars: ✭ 223 (+829.17%)
Mutual labels:  aspnetcore
Idunno.authentication
A filled with self-loathing implementation of Basic Authentication, and Certificate Authentication to make me feel like a real security person, all for for ASP.NET Core
Stars: ✭ 228 (+850%)
Mutual labels:  aspnetcore
Angularspawebapi
Angular Single Page Application with an ASP.NET Core Web API that uses token authentication
Stars: ✭ 222 (+825%)
Mutual labels:  aspnetcore
Restairline
DDD+CQRS+EventSourcing+Hypermedia API+ASP.NET Core 3.1+Masstransit+terraform+docker+k8s
Stars: ✭ 243 (+912.5%)
Mutual labels:  aspnetcore
Serilog Extensions Logging
Serilog provider for Microsoft.Extensions.Logging
Stars: ✭ 215 (+795.83%)
Mutual labels:  aspnetcore
Aspnetcore Vueclimiddleware
Helpers for building single-page applications on ASP.NET MVC Core using Vue Cli or Quasar Cli.
Stars: ✭ 253 (+954.17%)
Mutual labels:  aspnetcore
Aspnetcore Vue Typescript Template
Template AspNetCore with Vue, Vue router, Vuex, TypeScript, Bulma, Sass and Jest
Stars: ✭ 215 (+795.83%)
Mutual labels:  aspnetcore
Run Aspnetcore
A starter kit for your next ASP.NET Core web application. Boilerplate for ASP.NET Core reference application, demonstrating a layered application architecture with applying Clean Architecture and DDD best practices. Download 100+ page eBook PDF from here ->
Stars: ✭ 227 (+845.83%)
Mutual labels:  aspnetcore
Identity.dapper
Identity package that uses Dapper instead EntityFramework for use with .NET Core
Stars: ✭ 234 (+875%)
Mutual labels:  aspnetcore
cpp20-internet-client
An HTTP(S) client library for C++20.
Stars: ✭ 34 (+41.67%)
Mutual labels:  https
SeoTags
SeoTags create all SEO tags you need such as meta, link, twitter card (twitter:), open graph (og:), and JSON-LD schema (structred data).
Stars: ✭ 113 (+370.83%)
Mutual labels:  aspnetcore

How to run ASP.NET Core app on HTTPS in Docker

This prove of concept demonstrates following topics:

  1. Configuration of HTTPS in ASP.NET Core app: Program.cs and Startup.cs
  2. Using SSL certificate file in ASP.NET Core app: localhost-dev.pfx
  3. Generating localhost development certifcate file: generate-dev-cert.ps1
  4. Running ASP.NET Core on HTTPS inside Docker container: Dockerfile and docker-compose.override.yml
  5. Configuring HTTPS ports for Visula Studio and Docker container: launchSettings.json and docker-compose.override.yml

Step 1: Generate a local development certificate

Execute Cert\generate-dev-cert.ps1 file which will create a certificate: Cert\localhost-dev.pfx with and auto-generated random password (a GUID) and saves that password in UserSecrets (secrets.json) for this project

Step 2: Run docker-compose

In the root catalog (where the docker-compose.yml file is) run command

docker-compose up -d --build

this will build docker image and create a docker container.

Step 3: Open a web browser

Open https://localhost:44309/api/values to confirm the app is running correctly.

Explanation

This PoC uses PowerShell script Cert\generate-dev-cert.ps1 which is using dotnet dev-certs tool to generate a certificate file Cert\localhost-dev.pfx with a random password (a GUID). This password and full path to the generated certificate file is then saved to User Secrets for the project.

Good starting point for HTTPS development is: Enforce HTTPS in ASP.NET Core

Main points

HTTPS is configured in Program.cs

.UseKestrel(options =>
    {
        //...
        options.Listen(IPAddress.Any, httpsPort, listenOptions =>
        {
            listenOptions.UseHttps(certPath, certPassword);
        });
    });

and Startup.cs

if (env.IsDevelopment())
{
    //...
}
else
{
    app.UseHsts();
}

app.UseHttpsRedirection();

HTTPS port and allowed urls are configured with environment variables defined in launchSettings.json (for running in Visual Studio) and docker-compose.override.yml (for running in Docker container)

"environmentVariables": {
    "ASPNETCORE_HTTPS_PORT": "44300",
    "ASPNETCORE_URLS": "https://*:443"
}
------
environment:
    - ASPNETCORE_HTTPS_PORT=44309
    - ASPNETCORE_URLS=https://+:443;http://+:80
    - CertPath=/app/cert/localhost-dev.pfx

Running in Visual Studio

When running in Visul Studio, HTTPS port and allowed urls are overriden by launchSettings.json. CertPath and CertPassword are stored in User Secrets for the project and used when running the application: configuration.GetValue<string>("CertPassword")

Running in Docker

When running in Docker, HTTPS port and allowed urls are overriden by docker-compose.override.yml

CertPassword is still stored in User Secrets for the project and is available inside Docker container by creating a volume linked to User Secrets folder on the host machine in docker-compose.override.yml

    volumes:
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro

CertPath in User Secrets is overriden by environment variable defined in docker-compose.override.yml. This is the same path as defined in Dockerfile: /app/cert/localhost-dev.pfx

ARG CERT_PATH_DEST=/app/cert/localhost-dev.pfx
ENV CertPath=$CERT_PATH_DEST
COPY Cert/localhost-dev.pfx $CertPath
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].