Skip to content

Use Nginx and mkcert to add HTTPS to your local development environment.

Notifications You must be signed in to change notification settings

oktadev/mkcert-nginx-example

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

localhost TLS

Access services on localhost:8080 via https://local.example using mkcert and Nginx.

Add local.example to hosts file:

sudo sh -c 'echo "127.0.0.1 local.example" >> /etc/hosts'

Create directories:

mkdir devcerts
mkdir logs

Set up certificates with mkcert

# Install mkcert if needed
brew install mkcert

mkcert --install
mkcert -key-file devcerts/key.pem -cert-file devcerts/cert.pem local.example

Start up Nginx

docker compose up

Start your application on port 8080

Access your service from https://local.example

NOTE: HTTPie does NOT use the system certificates, you must point to the mkcert's directly

http --verify="$(mkcert --CAROOT)/rootCA.pem" https://local.example

Or set up an alias:

alias http="http --verify=\"$(mkcert --CAROOT)/rootCA.pem\""

About

Use Nginx and mkcert to add HTTPS to your local development environment.

Topics

Resources

Code of conduct

Stars

Watchers

Forks