Posted at

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

More than 1 year has passed since last update.

:writing_hand: 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" ✅


nginx.conf

    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


結果

スクリーンショット 2018-07-25 21.18.33.png

スクリーンショット 2018-07-25 21.21.46.png

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