mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
adding x-forward headers
This commit is contained in:
parent
598a1b4419
commit
51ca59a4f3
1 changed files with 11 additions and 0 deletions
|
@ -35,6 +35,12 @@ router.use(function (req, res, next) {
|
|||
req.on('end', next);
|
||||
});
|
||||
|
||||
function getPort(req) {
|
||||
var matches = req.headers.host.match(/:(\d+)/);
|
||||
if (matches[1]) return matches[1];
|
||||
return req.connection.pair ? '443' : '80';
|
||||
}
|
||||
|
||||
// Create the proxy middleware
|
||||
router.use(function (req, res, next) {
|
||||
|
||||
|
@ -47,6 +53,11 @@ router.use(function (req, res, next) {
|
|||
timeout: config.kibana.request_timeout
|
||||
};
|
||||
|
||||
|
||||
options.headers['x-forward-for'] = req.connection.remoteAddress || req.socket.remoteAddress;
|
||||
options.headers['x-forward-port'] = getPort(req);
|
||||
options.headers['x-forward-proto'] = req.connection.pair ? 'https' : 'http';
|
||||
|
||||
// If the server has a custom CA we need to add it to the agent options
|
||||
if (hasCustomCA) {
|
||||
options.agentOptions = { ca: https.globalAgent.options.ca };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue