如何在nginx配置ssl?
1.在百度云下载证书,证书格式选择nginx.
2.配置nginx.conf
server {
listen 443 ssl;
server_name localhost;
ssl_certificate www.***.cn.crt;
ssl_certificate_key www.***.cn.key;
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;
}
}
nginx报错:nginx: [emerg] bind() to 0.0.0.0:443 failed (10013: An attempt was made to acces
s a socket in a way forbidden by its access permissions)
解决方案:
运行 cmd, 输入netstat -aon|findstr “443”
找到 0.0.0.0:443,找到 PID,在任务管理器结束进程。然后重新启动nginx即可。