Hi 🙋‍♀️about me 😎posts 📚

銀河一の早さでlocalhost(macOS)をHTTPS化する(nginxとmkcertで)

mkcert

手順

$ brew install nginx
$ brew install mkcert
$ brew install nss
$ mkcert -install
$ cd /usr/local/etc/nginx/
$ mkcert localhost 127.0.0.1 ::1
# Created a new certificate valid for the following names 📜
#  - "localhost"
#  - "127.0.0.1"
# - "::1"

# The certificate is at "./localhost+2.pem" and the key at "./localhost+2-key.pem" ✅
    server {
       listen       443 ssl;
       server_name  localhost;

       ssl_certificate      /usr/local/etc/nginx/localhost+2.pem;
       ssl_certificate_key  /usr/local/etc/nginx/localhost+2-key.pem;

       ssl_session_cache    shared:SSL:1m;
       ssl_session_timeout  5m;

       ssl_ciphers  HIGH:!aNULL:!MD5;
       ssl_prefer_server_ciphers  on;

       location / {
           root   html;
           index  index.html index.htm;
       }
    }
$ sudo nginx

結果

:moyai: 「...あとは好きにプロキシしてや」