运行环境与证书准备
环境信息
操作系统环境为CentOS 6.7。
使用的Web服务器软件版本为nginx/1.8.1。
证书文件准备
# ls /opt/nginx/conf/ssl
qingkang.me.crt # 公钥
qingkang.me.key # 私钥
配置文件修改
vim nginx.conf
打开nginx.conf配置文件,定位到关于HTTPS服务器的配置区块。
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.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;
# }
#}
将原有的注释代码块替换为具体的服务器配置指令。
server {
listen 443 ssl;
server_name qingkang.me;
ssl_certificate ssl/qingkang.me.crt;
ssl_certificate_key ssl/qingkang.me.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;
}
}
验证配置文件的语法是否正确。
/opt/nginx/sbin/nginx -t
重新加载Nginx服务以使更改生效。
/opt/nginx/sbin/nginx -s reload
总结
以上内容涵盖了从环境确认到证书生效的全过程,希望能为相关学习者提供实用参考。如有疑问欢迎留言交流。