配置需要有自己的域名和云主機(jī);域名已經(jīng)解析到主機(jī);安裝好Nginx
一、申請免費版的SSL證書
1、阿里云可以申請免費版的SSL證書
阿里云搜索 ssl 找到 數(shù)字證書管理服務(wù)/SSL 證書>免費證書;申請一個免費的
2、下載SSL證書到本地(pem/key)
選擇其他類型,圖中的Nginx的不行;將其放到服務(wù)器的/opt/ssl/sslOther/
目錄下
二、配置Nginx文件
使用Vim編輯在/etc/nginx
目錄下的nginx.conf
文件
1、解除掉 # Settings for a TLS enabled server.以下的注釋
2、servername 對應(yīng)到 自己的域名
3、對應(yīng)到剛才下載的SSL證書,其中 ssl_certificate 對應(yīng) pem ,ssl_certificate_key 對應(yīng) key。
其他、默認(rèn)即可文章來源:http://www.zghlxwxcb.cn/news/detail-438677.html
# Settings for a TLS enabled server.
server {
listen 443 ssl;
# listen [::]:443 ssl http2;
server_name nidemiao.cn;
root /usr/share/nginx/html;
ssl_certificate "/opt/sslOther/9385966_nidemiao.cn.pem";
ssl_certificate_key "/opt/sslOther/9385966_nidemiao.cn.key";
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
三、重啟Nginx
以下是相關(guān)命令,選那個reload的就行文章來源地址http://www.zghlxwxcb.cn/news/detail-438677.html
# 相關(guān)操作
systemctl start nginx.service
systemctl stop nginx.service
systemctl reload nginx.service
systemctl status nginx.service
# 設(shè)置上開機(jī)自啟動
systemctl enable nginx.service
# 停止開機(jī)自啟動
systemctl disable nginx.service
到了這里,關(guān)于【Nginx】【SSL】Nginx上配置ssl證書的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!