如何解决让 ExpresJS 处理 SSL 证书和 NginX 转发端口
我在端口 8443
上有一个 Expressjs HTTPS 服务器列表,我想使用 Nginx 将 443
请求转发到我的 https 服务器。
const fs = require('fs');
const key = fs.readFileSync('/etc/letsencrypt/live/example.com/privkey.pem','utf8');
const cert = fs.readFileSync('/etc/letsencrypt/live/example.com/cert.pem','utf8');
const credentials = { key,cert };
const httpsServer = require('https').createServer(credentials,app);
httpsServer.listen(8443);
Nginx 配置:
server {
listen 443;
server_name example.com;
location / {
proxy_pass http://localhost:8443;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_read_timeout 86400;
}
}
但是当我访问 https://example.com
时,页面刚刚损坏。我做错了什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。