Better Programming

Advice for programmers.

Follow publication

Member-only story

NGINX with Self-Signed Certificate on Docker

Nassos Michas
Better Programming
Published in
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

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

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)

Write a response