【发布时间】:2018-05-09 10:07:48
【问题描述】:
我按照本教程使用 SSL 保护 NGINX:https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04
我明确选择将所有请求重定向到 HTTPS
现在,当访问我的网页 www.example.com 时,它会正确地将我重定向到 https://www.example.com 并显示默认的 NGINX 文本。
我想让 Express 在那里运行,所以我制作了这个小脚本来测试一下:
var https = require('https');
var fs = require('fs');
var options = {
key: fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem'),
ca: fs.readFileSync('/etc/letsencrypt/live/example.com/chain.pem')
};
https.createServer(options, function (req, res) {
res.writeHead(200);
res.end("hello world\n");
}).listen(8000);
页面根本不会加载。我做错了什么?
【问题讨论】:
标签: node.js nginx https lets-encrypt