brew install mkcert
mkcert -install
mkcert local.place-your-domain-here.com localhost 127.0.0.1 ::1
Two .pem
files will be generated. rename them as domain.pem
and domain-key.pem
add 127.0.0.1 local.place-your-domain-here.com
to your /private/etc/hosts
file
touch nginx.conf
events {
}
http {
server {
listen 443 ssl;
listen [::]:443 ssl;
ssl_certificate ~/domain.pem;
ssl_certificate_key ~/domain-key.pem;
server_name local.place-your-domain-here.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
}
nginx -c nginx.conf -p .
now you can open https://local.place-your-domain-here.com
My nginx server is on WSL Ubuntu. I tried mkcert in WSL and import RootCA.pem in the host machine but still gets an error. Then I run mkcert in Windows cmd and copy generated certs to WSL and the error goes away :)