【发布时间】:2017-06-20 20:49:52
【问题描述】:
我正在尝试验证请求以查看它是 HTTPS 还是 HTTP。我的 express 应用程序在端口 1337 上运行。Apache 用作反向代理,在端口 80 上没有 ssl 证书,在端口 443 上用于 https 请求。
我尝试了以下方法:
console.log("Is secure HTTPS: "+req.secure);
console.log("Is encrypted: "+req.connection.encrypted);
console.log("Proxy "+req.header('x-forwarded-proto'));
console.log(req.headers['x-forwarded-proto'])
当使用 https 从 chrome 请求时,它会打印:
Is secure HTTPS: false
Is encrypted: undefined
Proxy undefined
undefined
【问题讨论】:
标签: node.js apache http express https