鍍金池/ 問答/HTML/ nginx 如何真確配置node 服務 https 請求

nginx 如何真確配置node 服務 https 請求

1.nginx 代碼配置如下

# HTTPS server
#
server {
  
    listen       80;
    listen       443 ssl;
    server_name  localhost;
    ssl_certificate  214329030340321.crt ;
    ssl_certificate_key 214329030340321.key;
    location / {
    proxy_pass http://localhost:3000;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection ‘upgrade';
    proxy_set_header Host $host;
    proxy_cache_bypass $http_upgrade;
    }
   

}

2.node服務代碼如下
var http = require('http');
var data = {key: 'value', hello: 'world'};
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'application/json'});
res.write('hello,world 世界');
res.end();
}).listen(3000);

http 可以正常響應, https 訪問不了,

回答
編輯回答
下墜

看一下本地的443端口是否開放,如果沒有開放,肯定不能訪問

2018年2月13日 02:41