X-Forwarded-Proto
 |
X-Forwarded-Proto on MDN |
To identify if a connection coming to your server is using HTTP - Hypertext Transfer Protocol or
HTTPS - Hypertext Transfer Protocol over
SSL / TLS, you can check
X-Forwarded-Proto header of the request.
Definitions on MDN
X-Forwarded-For is the standard header to identify the original IP address of a client that connects to a server proxy or load balancer.
X-Forwarded-Proto is the standard header to identify the protocol used by the client to connect to a server proxy or load balancer.
X-Forwarded-Host is the standard header to identify the original host requested by the client in the Host HTTP request header.
Node.js
...
var app = express();
var checkProtocol = function (req, res, next) {
console.log(req.headers['x-forwarded-for']);
console.log(req.headers['x-forwarded-host']);
console.log(req.headers['x-forwarded-proto']);
console.log(req.headers.host);
console.log(req.url);
};
app.use(checkProtocol);
...
Thanks for reading!
Jun
Comments
Post a Comment