title: nginx config, websocket proxy, location, if
body: <p>I have a very specific nginx config question:</p>
  
  <p>I need nginx to:</p>
  
  <ul>
  <li>proxy websocket connections @ /</li>
  <li>respond with index.html for standard http requests @ /</li>
  </ul>
  
  <p>This is the closest I can get:</p>
  
  <pre><code>  location = / {
     if ($http_upgrade != "websocket") {
      # Here lies my problem:
      # This returns a http: 302 where i just need it to return the contents
      # of index.html
      return https://admin.permaconn.com/index.html;
     }
  
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "upgrade";
     proxy_pass http://localhost:8080;
    }
  </code></pre>
  
  <p>I am undergoing a structural change with my app from using nodejs as a front proxy to nginx as a front end proxy.</p>
  
  <p>I must configure nginx this way due to expected behaviour from numerous programs already installed devices (aka legacy).</p>