title: Redirect websocket to application behind gateway
body: <p>I have an application which lies behind authorization gateway, whhich is another java application. I am trying to redirect websocket connection from UI to target application. I managed to add cookies needed to create websocket handshake, but when it comes to request upgrade to websocket - it fails, because &quot;Upgrade&quot; is a restricted headed. I am using spring rest template to communicate between applications. And spring websocket, with socks support.</p>
  <p>Am i doing it wrong? Maybe there is a different approach? Cause for now task seem to be strangely difficult and i am starting to think that this should be easier</p>
  <p>my ui application sends request like</p>
  <pre><code>Host: localhost:8082
  Connection: Upgrade
  Pragma: no-cache
  Cache-Control: no-cache
  User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36
  Upgrade: websocket
  Origin: http://localhost:3000
  Sec-WebSocket-Version: 13
  Accept-Encoding: gzip, deflate, br
  Accept-Language: en-US,en;q=0.9,ru;q=0.8
  Sec-WebSocket-Key: 1bydSfgOd7p8VeSXgtBWeA==
  Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
  </code></pre>
  <p>Gateway application receives it, and tries to redirect to my app with sockets, but inside HttpURLConnection class
  there is</p>
  <pre><code>private static final String[] restrictedHeaders 
  </code></pre>
  <p>which contains Upgrade header.
  so my application receives something like this</p>
  <pre><code>GET /ws-message/264/1e2zkk3t/websocket HTTP/1.1
  Accept: text/plain, application/json, application/*+json, */*
  pragma: no-cache
  cache-control: no-cache
  user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36
  accept-encoding: gzip, deflate, br
  accept-language: en-US,en;q=0.9,ru;q=0.8
  Host: localhost:8080
  Connection: keep-alive
  </code></pre>
  <p>and it fails due to handshake</p>
  <pre><code> ERROR 23540 --- [nio-8080-exec-5] o.s.w.s.s.s.DefaultHandshakeHandler      : Handshake failed due to invalid Upgrade header: null
  </code></pre>
  <p>exact code in AbstractHandshakeHandler</p>
  <pre><code>            if (!&quot;WebSocket&quot;.equalsIgnoreCase(headers.getUpgrade())) {
                  handleInvalidUpgradeHeader(request, response);
                  return false;
  </code></pre>
  <p>What can i do about all of this?</p>