如何检测在Azure网站HTTPS的重定向? [英] How to detect HTTPS redirection on Azure Websites?
本文介绍了如何检测在Azure网站HTTPS的重定向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
按标题,我有一个Node.js应用程式,我希望能够检测请求是否正在取得通过HTTPS或HTTP。到目前为止,我重定向是这样的:
As per the title, I have a Node.js application and I want to be able to detect whether a request is being made over HTTPS or HTTP. So far my redirection looks like this:
// Ensure the page is secure, or that we are running a development build
if (req.headers['x-forwarded-proto'] === 'https' || process.env.NODE_ENV === 'development') {
res.render('index');
} else {
winston.info('Request for login page made over HTTP, redirecting to HTTPS');
res.redirect('https://' + req.host);
}
这适用于Nodejitsu很好,但重定向HTTPS请求不具有的X - 转发,原头在Azure上设置的。
Which works fine on Nodejitsu, but a redirected HTTPS request doesn't have the 'x-forwarded-proto' header set on Azure.
推荐答案
我想我是在我的意见正确的:
I think I was correct in my comment:
X-ARR-SSL
似乎是检查头。
// Ensure the page is secure, or that we are running a development build
if (req.headers['x-forwarded-proto'] === 'https' || req.headers['x-arr-ssl'] || process.env.NODE_ENV === 'development') {
res.render('index');
} else {
winston.info('Request for login page made over HTTP, redirecting to HTTPS');
res.redirect('https://' + req.host);
}
这篇关于如何检测在Azure网站HTTPS的重定向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文