title: WebSocket through SSL with Apache reverse proxy
body: <p>On the client side, I am trying to establish the wss connection:</p>
  
  <p><code>var ws = new WebSocket("wss://wsserver.com/test")</code></p>
  
  <p>and it returns an error:</p>
  
  <p><code>WebSocket connection to 'wss://wsserver.com/test' failed: Error during WebSocket handshake: Unexpected response code: 400</code></p>
  
  <p>The full headers are:</p>
  
  <p><strong>Request Headers</strong></p>
  
  <pre><code>GET wss://wsserver.com/test HTTP/1.1
  Host: wsserver.com
  Connection: Upgrade
  Pragma: no-cache
  Cache-Control: no-cache
  Upgrade: websocket
  Origin: https://website.net
  Sec-WebSocket-Version: 13
  User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36
  Accept-Encoding: gzip, deflate, sdch, br
  Accept-Language: en-US,en;q=0.8
  Sec-WebSocket-Key: Tj9AJ5TKglNf5LoHsQTpvQ==
  Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
  </code></pre>
  
  <p><strong>Response Headers</strong></p>
  
  <pre><code>Access-Control-Allow-Credentials:true
  Access-Control-Allow-Origin:https://website.net
  Connection:close
  Content-Length:18
  Content-Type:text/plain; charset=utf-8
  Date:Fri, 21 Apr 2017 21:03:45 GMT
  Server:Apache/2.4.18 (Ubuntu)
  Vary:Origin
  X-Content-Type-Options:nosniff
  </code></pre>
  
  <p>The server side is running on go at port 8888 behind an Apache reverse proxy. This is the Apache configuration:</p>
  
  <pre><code>&lt;VirtualHost *:443&gt;
          ServerName website.com
  
          ProxyPreserveHost On
          ProxyRequests Off
          ProxyPass "/" "wss://localhost:8888/"
  </code></pre>
  
  <p><em>mod_proxy</em> and <em>mod_proxy_wstunnel</em> are installed.</p>
  
  <p>Is there something missing here? It seems like the request goes through but no connection is established. </p>