我试图识别我的快速应用程序是否通过https协议提供服务。
使用nginx处理认证和加密(在同一台计算机上)并转发请求,即使使用https且工作正常也可以req.protocol评估http。
我已经尝试了以下两种方法(分别):
app.set('trust proxy', 'loopback');
Run Code Online (Sandbox Code Playgroud)
和
app.enable('trust proxy');
Run Code Online (Sandbox Code Playgroud)
然而,req.protocol仍然报告http。
是什么赋予了?
这里是req.header:
{ 'x-real-ip': '196.38.239.10',
'x-forwarded-for': '196.38.239.10',
host: 'idwork.co',
'x-nginx-proxy': 'true',
connection: 'close',
'content-length': '0',
'cache-control': 'no-cache',
origin: 'file://',
'content-type': 'application/json',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_4) AppleWebKit/537.36 (KHTML, like Gecko) Postman/4.3.2 Chrome/47.0.2526.73 Electron/0.36.2 Safari/537.36',
'postman-token': 'redacted',
accept: '*/*',
'accept-encoding': 'gzip, deflate',
'accept-language': 'en-US' }
Run Code Online (Sandbox Code Playgroud)
这是我相关的(?)Nginx转发规则:
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For …Run Code Online (Sandbox Code Playgroud)