配置https Published on Dec 3, 2020 in linuxmac with 0 comment ## 配置本地https #### 首先我们需要ssl证书 这里我们使用[mkcert](https://github.com/FiloSottile/mkcert)生成证书,我们来安装一下这个命令: ```bash brew install mkcert ``` 这里我们配置 `blog.com` 域名为例 生成证书 ```bash mkcert blog.com aiPlatform.dev localhost 127.0.0.1 ::1 blog.com ``` 安装生成的证书,让系统授信任 ```bash mkcert -install ``` #### 配置nginx ```nginx server { listen 443 ssl; server_name blog.com; ssl_certificate /Users/tzjvon/Desktop/ssl/blog.com+5.pem; ssl_certificate_key /Users/tzjvon/Desktop/ssl/blog.com+5-key.pem; root /Users/tzjvon/nginx/typecho_blog; index index.html index.php index.htm default.html default.php default.htm; location ~ .*\.php(\/.*)*$ { include fastcgi.conf; fastcgi_pass 127.0.0.1:9000; } } server { listen 80; server_name blog.com; rewrite ^(.*)$ https://blog.com$1 permanent; } ``` 重启nginx ``` sudo nginx -s reload ``` 大功告成 本文由 tutustack 创作,采用 知识共享署名4.0 国际许可协议进行许可本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名