Sitemap
Better Programming

Advice for programmers.

Member-only story

NGINX with Self-Signed Certificate on Docker

7 min readApr 13, 2023

--

Photo by FLY:D on Unsplash

While working with our code, we often need to quickly check if something works under HTTPS — or more importantly, how it behaves under HTTPS. There are plenty of guides online showing you how to create a Certificate Sign Request (CSR), how to self-sign that CSR, and how to manually modify your web server’s configuration to make it use that certificate.

In this article, I will present a fully-automated process using Docker to quickly spin up an NGINX container with a self-signed certificate — all without having to generate or manually edit anything at all!

Security note and warning

  1. A self-signed certificate can only be trusted by… you. It is not a means to serve data in a production environment; use a proper certificate in such cases.
  2. The NGINX configuration to serve content under HTTPS presented in this article is the bare minimum to get the job done. If you want to modify a production NGINX with TLS, please consult the official guide.

If you are just starting with Public Key Cryptography, I have written an introduction article you might find useful.

Build design

--

--

Nassos Michas
Nassos Michas

Written by Nassos Michas

BSc, MSc in Software engineering | Cert. Scrum master | Cert. Professional for Software Architecture | Cert. Professional for Requirements Engineering

Responses (1)