一、首先要去騰訊云申請(qǐng)
申請(qǐng)成功后,你直接下載證書(shū)就可以用了。
二、配置nginx
在/etc/nginx/conf.d/
下加入你的域名配置比如xxx.com.conf,內(nèi)容如下
server { listen 80; listen 443 ssl; server_name www.xxx.com; ssl_certificate /etc/nginx/ssl/www.xxx.com_cert.crt; ssl_certificate_key /etc/nginx/ssl/www.xxx.com.key; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://127.0.0.1:8360; }}
proxy_pass
即反向代理到你的node服務(wù)的地址。
sslcertificate
和 sslcertificate_key
需要指定證書(shū)目錄文件,也就是將你下載的文件復(fù)制到/etc/nginx/ssl
目錄中去就行啦。
三、最后重啟nginx就可以咯。非常簡(jiǎn)單啦。
Note 切換到https麻煩的事情就來(lái)了,https不允許http資源的加載請(qǐng)求,因此最好將那些地址替換掉支持https。
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家學(xué)習(xí)或者使用node.js能有所幫助,如果有疑問(wèn)大家可以留言交流。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注