Proxy redirecting websockets and http to the same (unix) socket
<p>I've made a little nginx conf to redirect trafic to a unix socket listened by a <code>daphne</code> server (server used for <code>django</code>).</p>

<p>According to the <a href="https://channels.readthedocs.io/en/latest/deploying.html#run-interface-servers" rel="nofollow">documentation</a> :</p>

<blockquote>
  <p>If you use Daphne for all traffic, it auto-negotiates between HTTP and
  WebSocket, so there’s no need to have your WebSockets on a separate
  port or path</p>
</blockquote>

<p><strong>So I'd like to proxy both websockets and Http trafic to the same unix socket.</strong></p>

<ol>
<li><p>Is it possible?</p></li>
<li><p>How could I do?</p></li>
</ol>

<p>Here is what I tried thus far :</p>

<pre><code>upstream django_ws {
         server unix:///path/to/ws.sock;
}

server {
       listen 8082;
       server_name 127.0.0.1;
       charset utf-8;

       root /path/to/root;

       set $myroot $document_root;

       location / {
                proxy_pass http://django_ws;
                #proxy_http_version 1.1;
                #proxy_set_header Upgrade websocket;
                #proxy_set_header Connection upgrade;
       }
}
</code></pre>

<ul>
<li><p>If I uncomment the lines in the location bloc, the page appears blank.</p></li>
<li><p>If I don't, the pages appear but the websockets don't seem to work.</p></li>
</ul>

<p>How could I solve this?</p>

<p>Everything works fine with the development server.</p>