title: Using NGINX + Socket.io while specifying socket room/namespace
body: <p>I just updated a node+socket app to use https.  It took a while, but I now have a working nginx, node.js, socket.io configuration here.  It works great, but my question is, is it possible to configure the server side so that the client doesn't need to submit the <code>path</code> parameter, or at least include it as part of the url?  I'd like to be able to give users just a url to use, for example, <code>https://mywebsite.com/apiPath/myNamespace</code>.</p>
  
  <p>Currently:</p>
  
  <p>NGINX CONFIG:</p>
  
  <pre><code>upstream websocket1 {
      server 127.0.0.1:3000;
  } 
  server {
      listen 80;
      listen [::]:80;
      server_name mywebsite.com;
      return 301 https://mywebsite.com$request_uri;
  }
  server {
          listen 443 ssl;
          server_name         mywebsite.com;
          ssl_certificate     this.crt;
          ssl_certificate_key this.pem;
          location /apiPath/ {
                  proxy_pass http://websocket1/socket.io/;
                  proxy_http_version 1.1;
                  proxy_set_header Upgrade $http_upgrade;
                  proxy_set_header Connection "Upgrade";
                  proxy_set_header X-Real-IP $remote_addr;
                  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          }
  }
  </code></pre>
  
  <p>SERVER:</p>
  
  <pre><code>var express = require('express');
  var app = express();
  
  var http = require('http').Server(app);
  var io = require('socket.io')(http);
  var port = process.env.PORT || 3000;
  http.listen(port);
  
  var nsp = io.of('/myNamespace');
  
  nsp.on('connection', function(socket) {
    console.log('connected!');
  });
  </code></pre>
  
  <p>CLIENT:</p>
  
  <p><code>var socket = require('socket.io-client')(https://mywebsite.com/myNamespace, {path: '/apiPath'});</code></p>
  
  <p>Thanks in advance!</p>