title: Apache redirect rules for back-end server with WebSockets
body: <p>I'm trying to figure out how to properly setup apache redirect rules for back-end CherryPy server which implements websocket (done via ws4py module). The problem is that if you use rewrite engine or proxypass it strips off <strong>Upgrade</strong> header in redirected request and therefore CherryPy server complaints about it and fails at handshake step.</p>
  
  <p>The scenario I have is the following. I have CherryPy server with ws4py module which setup WebSockets. It runs on localhost:9000. I want to have apache front-end which just redirect incoming request to back-end server (it does more than that, but for simplicity it should do just that).</p>
  
  <p>The apache rule I have is simple</p>
  
  <pre><code>RewriteRule ^(/websocket(/.*)?)$ http://some_host:9000$1 [P,L]
  </code></pre>
  
  <p>so for all requests starting with /websocket it redirects them to back-end server running on port 9000. The P flag stands for Proxy, the L stops rewriting process (see <a href="http://borkweb.com/story/apache-rewrite-cheatsheet" rel="nofollow">http://borkweb.com/story/apache-rewrite-cheatsheet</a>)</p>
  
  <p>If client sends request with HTTP header <strong>Upgrade:websocket</strong> the apache engine (rewrite module) strips it off, which causes WebSocket handshake fails.</p>
  
  <p>Is there are any way to fix rewrite rule to allow presence of <strong>Upgrade</strong> header?</p>