backport of commit 99e54da9a9aeb3a62a05f50af1dcc74c06cd9657 (#18797)

Co-authored-by: Luiz Aoqui <luiz@hashicorp.com>
This commit is contained in:
hc-github-team-nomad-core 2023-10-18 09:22:36 -05:00 committed by GitHub
parent 897bcef932
commit 8f1713dcd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 8 deletions

View File

@ -45,13 +45,10 @@ module.exports = function (app, options) {
proxy.web(req, res, { target: proxyAddress });
});
server.on('upgrade', function (req, socket, head) {
if (
req.url.startsWith('/v1/client/allocation') &&
req.url.includes('exec?')
) {
req.headers.origin = proxyAddress;
proxy.ws(req, socket, head, { target: proxyAddress });
}
server.on('upgrade', function (req) {
// Set Origin header so Nomad accepts the proxied request.
// WebSocket proxing is handled by ember-cli.
// https://github.com/ember-cli/ember-cli/blob/v3.28.5/lib/tasks/server/middleware/proxy-server/index.js#L51
req.headers.origin = proxyAddress;
});
};