Add HTTPS (SSL cert) to Docker hosted ASP.net core Webserver

 

Adding HTTPS to your Docker webserver is ridiculously easy. This is accomplished by using Caddy 2, a webserver that automatically generates and updates the SSL certificate, as a reverse proxy.

There are two basic steps:

  1. Get your free No-IP domain and install the No-IP client (on your server)
  2. Run the Docker compose for Caddy 2

--docker-compose.yml--

version: '3.4'

services:
  caddy:
    image: caddy:2.4.6-alpine
    restart: always
    command: caddy reverse-proxy --from <no-ip url here> --to <your webserver container>:80
    ports:
       - "80:80"
       - "443:443"
    volumes:
       - caddy:/data
       # Uncomment below to use a Caddyfile in the same directory as this file. - don't forget to comment command: (line 7)
       #- ./:/etc/caddy/

volumes: # Top-level key. Declares volumes which can be referenced from multiple services.
   caddy:

networks:
   default:
      external: true
      name: <network your server container is on>


--------------------------------------------------------
What happens:


Comments