mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
URI-encode forwarded location header in proxy
Right now there are situations in which ElasticSearch puts characters in the character code range between 128 and 255 into the `Location` header. This leads to an exception when trying to pass on that header through the hapi proxy in versions before 15.0.0, because it validates that only US-ASCII characters are used in headers. To work around that situation, the `Location` header is encoded using `encodeURI()` for now. Closes #8705
This commit is contained in:
parent
d0992b8789
commit
18c23c17d9
1 changed files with 8 additions and 1 deletions
|
@ -20,7 +20,14 @@ function createProxy(server, method, route, config) {
|
|||
xforward: true,
|
||||
timeout: server.config().get('elasticsearch.requestTimeout'),
|
||||
onResponse: function (err, responseFromUpstream, request, reply) {
|
||||
reply(err, responseFromUpstream);
|
||||
const upstreamLocation = responseFromUpstream.headers.location;
|
||||
const response = reply(err, responseFromUpstream);
|
||||
|
||||
// Workaround for #8705 until hapi has been updated to >= 15.0.0
|
||||
if (upstreamLocation) {
|
||||
delete responseFromUpstream.headers.location;
|
||||
response.location(encodeURI(upstreamLocation));
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue