您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Node.js开启Https的实践详解

2024/3/8 11:23:35发布39次查看
一、首先要去腾讯云申请
申请成功后,你直接下载证书就可以用了。
二、配置nginx
在/etc/nginx/conf.d/下加入你的域名配置比如xxx.com.conf,内容如下
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服务的地址。
sslcertificate 和 sslcertificate_key 需要指定证书目录文件,也就是将你下载的文件复制到/etc/nginx/ssl 目录中去就行啦。
三、最后重启nginx就可以咯。非常简单啦。
note 切换到https麻烦的事情就来了,https不允许http资源的加载请求,因此最好将那些地址替换掉支持https。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product