前言
Nginx配置SSL,实现HTTPS访问
正文
- 修改Nginx配置文件,追加一个server代码块
example.com:指定域名
<file>.crt、<file>.cer、<file>.pem:指定fullchain证书文件路径
<file>.key:指定私钥文件路径
/etc/nginx/nginx.conf1 2 3 4 5 6 7 8 9 10 11 12 13 14
| server { listen 443 ssl; server_name example.com;
ssl_certificate <file>.crt; ssl_certificate_key <file>.key;
ssl_session_timeout 5m;
location / { root html; index index.html index.htm; } }
|
踩坑
- 报错:
nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in ...
原因
解决问题
1
| ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
|
完成
参考文献
腾讯云文档——Nginx 服务器 SSL 证书安装部署
博客园——ノGHJ