Adding support for request timeout

This commit is contained in:
Chris Cowan 2015-01-20 11:41:49 -07:00
parent 89e082b2c4
commit 382227a089
2 changed files with 5 additions and 3 deletions

View file

@ -74,7 +74,7 @@
"grunt-s3": "~0.2.0-alpha.3",
"grunt-saucelabs": "~8.3.2",
"html-entities": "^1.1.1",
"http-proxy": "~1.1.4",
"http-proxy": "~1.8.1",
"husky": "~0.6.0",
"istanbul": "~0.2.4",
"load-grunt-config": "~0.7.0",

View file

@ -1,10 +1,11 @@
var logger = require('../lib/logger');
var express = require('express');
var router = module.exports = express.Router();
var httpProxy = require('http-proxy');
var config = require('../config');
var url = require('url');
var target = url.parse(config.elasticsearch);
var proxy = new httpProxy.createProxyServer();
var proxy = new httpProxy.createProxyServer({});
var buffer = require('buffer');
proxy.on('proxyReq', function (proxyReq, req, res, options) {
@ -43,7 +44,8 @@ router.use(function (req, res, next) {
var options = {
target: config.elasticsearch,
secure: config.kibana.verify_ssl,
xfwd: true
xfwd: true,
timeout: (config.kibana.request_timeout) * 1000
};
proxy.web(req, res, options);
});