title: NGINX with Express.js & socket.io | Cannot GET
body: <p>I have a <code>node/express.js/socket.io</code> app setup on an Ubuntu Server running on port 3002. I've opened up all ports on the machine. </p>
  
  <p>When I go to <code>11.111.111.1:3002/</code> everything works perfectly (both socket.io &amp; express.js). I'm trying to proxy-pass the app to <code>/mediaDev/</code> which seems to work in that I get an error message from express.js or node which says: </p>
  
  <blockquote>
    <p>"Cannot GET /mediaDev"</p>
  </blockquote>
  
  <p>Where as either not finding the node app returns 502 Bad Gateway. </p>
  
  <p>But going directly to the app at my IP address plus port the app works perfectly just as expected.</p>
  
  <p>Simplified NGINX:</p>
  
  <pre><code>server {
    listen 80 default_server;
    listen [::]:80 default_server;
  
    server_name _;
  
    location ~ ^/mediaDev {
      proxy_pass http://localhost:3002;
    }
  }
  </code></pre>
  
  <p>node.js related to serving content:</p>
  
  <pre><code>var app = express()
  app.user(bodyParser.urlencoded({ extended:false}))
  app.use(bodyParser.json())
  
  app.set('views', path.join(__dirname, 'views'))
  app.set('view engine', 'ejs')
  
  app.get('/', function (req, res) {
    res.render('index')
  })
  
  var server = app.listen(PORT, function () {
    console.log("listening on port 3002")
  })
  
  var io = require('socket.io')(server, {
    path: '/mediaDev/socket.io'
  })
  </code></pre>
  
  <p>Note: on the IP address both express.js and socket.io are working. On the actual domain express returned the error but my socket.io path <code>/mediaDev/socket.io</code> still works.</p>
  
  <p>I thought the above was a bit strange. If I'm proxy passing <code>/mediaDev</code> and making my socket.io path <code>/mediaDev/socket.io</code> shouldn't I expect an error and that to actually be at <code>/mediaDev/mediaDev/socket.io</code>?</p>