nginx配置ssl证书实现https (只有ssl.key和ssl.crt文件时)

生成ssl.pem文件
openssl x509 -inform PEM -in ssl.crt > ssl.pem
下列不在你配置文件中的字段添加上。server_name 为你自己的域名.
ssl.pem path: /etc/nginx/cert/ssl.pem
ssl.key path: /etc/nginx/cert/ssl.key

server {
listen 443 ssl;
server_name bjubi.com;
ssl_certificate  cert/ssl.pem;
ssl_certificate_key cert/ssl.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
}
server {
    listen 80;
    server_name bjubi.com;
    rewrite ^(.*)$ https://$host$1 permanent;
} 

nginx 命令

# 重启
service nginx restart
# 启动
service nginx start
# 停止
service nginx stop
# 查看当前启动的nginx的状态
systemctl status nginx.service 

您可能还会对下面的文章感兴趣: