Nginx怎么配置SSL證書監聽443端口

一、準備證書文件

我使用的是阿里云symantec 免費版 ssl證書。將證書文件下載后解壓得到如下文件

Nginx怎么配置SSL證書監聽443端口

nginx–>cert目錄中建一個ssl目錄,將上面的所有文件拷貝到ssl目錄中

二、修改nginx.conf文件

在nginx.conf的http{}中填下如下內容

server?{ ?listen?443; ?server_name?www.httpstest.com; ?ssl?on; ?root?html; ?index?index.html?index.htm; ?#這里的.pem/.key文件替換成自己對應的文件名 ?ssl_certificate?cert/xxxxx.pem; ?ssl_certificate_key?cert/xxxx.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; ?location?/?{ ??#代理的目標地址 ??proxy_pass?http://127.0.0.1:10443; ?} }

最后別忘了重啟nginx服務。

? 版權聲明
THE END
喜歡就支持一下吧
點贊8 分享