生成证书 openssl
- 下载openssl
- 配置环境变量名OPENSSL_HOME,然后加到path中
生成 key
openssl genrsa -des3 -out test.key 1024
生成 csr
openssl req -new -key test.key -out test.csr
- 去除密码
在加载SSL支持的Nginx并使用上述私钥时除去必须的口令,否则会在启动nginx的时候需要输入密码。
复制test.key并重命名为test.key.org
去除口令,在命令行中执行此命令: openssl rsa -in test.key.org -out test.key
生成crt证书
openssl x509 -req -days 365 -in test.csr -signkey test.key -out test.crt
nginx操作
修改nginx目录下的 conf/nginx.conf
server {
listen 5000 ssl;
#server_name www.test.com;
ssl_certificate D:/nginx-1.18.0/ssl/shidian.crt;
ssl_certificate_key D:/nginx-1.18.0/ssl/shidian.key;
#ssl_session_cache shared:SSL:1m;
#ssl_session_timeout 5m;
#ssl_ciphers HIGH:!aNULL:!MD5;
#ssl_prefer_server_ciphers on;
location / {
root D:/demo/www;
index index.html index.htm;
}
#location / {
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header Host $http_host;
# proxy_pass http://127.0.0.1:5000;
#
#}
}