eye*_*mew 2 https nginx node.js express
我试图识别我的快速应用程序是否通过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 $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass 127.0.0.1:1234;
proxy_redirect off;
}
Run Code Online (Sandbox Code Playgroud)
我需要将其添加到我的nginx块中:
proxy_set_header X-Forwarded-Proto https;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
563 次 |
| 最近记录: |